axmol/extensions/CCArmature/external_tool/CCTexture2DMutable.h

87 lines
2.2 KiB
C
Raw Normal View History

2013-06-06 12:02:54 +08:00
//
// Texture2DMutable.h
2013-06-06 12:02:54 +08:00
// Ported to C++ by Dmitry Matyukhin
//
// MutableTexture.m
2013-06-06 12:02:54 +08:00
// Created by Lam Hoang Pham.
// Improved by Manuel Martinez-Almeida.
//
#ifndef Texture2DMutable_cpp
#define Texture2DMutable_cpp
2013-06-06 12:02:54 +08:00
#include "cocos2d.h"
#define CC_MUTABLE_TEXTURE_SAVE_ORIGINAL_DATA 0
class Texture2DMutable : public cocos2d::Texture2D
2013-06-06 12:02:54 +08:00
{
#if CC_MUTABLE_TEXTURE_SAVE_ORIGINAL_DATA
CC_PROPERTY_READONLY(void*, originalData_, OriginalTexData);
#endif
CC_PROPERTY(void*, data_, TexData);
unsigned int bytesPerPixel_;
bool dirty_;
cocos2d::Image *image_;
2013-06-06 12:02:54 +08:00
public:
Texture2DMutable(void);
~Texture2DMutable(void);
2013-06-06 12:02:54 +08:00
void restore();
/** These functions are needed to create mutable textures */
void releaseData(void *data);
void* keepData(void *data, unsigned int length);
bool initWithImageFile(const char *imageFile, cocos2d::Texture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const cocos2d::Size& contentSize);
2013-06-06 12:02:54 +08:00
bool initWithImageFile(const char *imageFilex);
/** Intializes with a texture2d with data */
bool initWithData(const void* data, cocos2d::Texture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const cocos2d::Size& contentSize);
2013-06-06 12:02:54 +08:00
cocos2d::ccColor4B pixelAt(const cocos2d::Point& pt);
2013-06-06 12:02:54 +08:00
///
// @param pt is a point to get a pixel (0,0) is top-left to (width,height) bottom-right
// @param c is a ccColor4B which is a colour.
// @returns if a pixel was set
// Remember to call apply to actually update the texture canvas.
///
bool setPixelAt(const cocos2d::Point& pt, cocos2d::ccColor4B c);
2013-06-06 12:02:54 +08:00
///
// Fill with specified colour
///
void fill(cocos2d::ccColor4B c);
///
// @param textureToCopy is the texture image to copy over
// @param offset also offset's the texture image
///
Texture2D* copyMutable(bool isMutable);
2013-06-06 12:02:54 +08:00
Texture2DMutable* copy();
2013-06-06 12:02:54 +08:00
void copy(Texture2DMutable* textureToCopy, const cocos2d::Point& offset);
2013-06-06 12:02:54 +08:00
///
// apply actually updates the texture with any new data we added.
///
void apply();
void *getData();
};
#endif // Texture2DMutable_cpp