diff --git a/cocos2dx/CCDeprecated.cpp b/cocos2dx/CCDeprecated.cpp index eb4f581917..0f2a0ebd09 100644 --- a/cocos2dx/CCDeprecated.cpp +++ b/cocos2dx/CCDeprecated.cpp @@ -145,4 +145,7 @@ const int kCCMenuStateTrackingTouch = Menu::STATE_TRACKING_TOUCH; const int kCCTouchesOneByOne = Layer::TOUCHES_ONE_BY_ONE; const int kCCTouchesAllAtOnce = Layer::TOUCHES_ALL_AT_ONCE; +const int kCCImageFormatPNG = Image::FORMAT_PNG; +const int kCCImageFormatJPEG = Image::FORMAT_JPG; + NS_CC_END \ No newline at end of file diff --git a/cocos2dx/include/CCDeprecated.h b/cocos2dx/include/CCDeprecated.h index 1bb016cbe9..88e5e4b411 100644 --- a/cocos2dx/include/CCDeprecated.h +++ b/cocos2dx/include/CCDeprecated.h @@ -902,8 +902,9 @@ CC_DEPRECATED_ATTRIBUTE extern const int kCCTouchesOneByOne; CC_DEPRECATED_ATTRIBUTE extern const int kCCTouchesAllAtOnce; CC_DEPRECATED_ATTRIBUTE typedef enum Layer::TouchesMode ccTouchesMode; -#define kCCImageFormatPNG kImageFormatPNG -#define kCCImageFormatJPEG kImageFormatJPEG +CC_DEPRECATED_ATTRIBUTE extern const int kCCImageFormatPNG; +CC_DEPRECATED_ATTRIBUTE extern const int kCCImageFormatJPEG; +CC_DEPRECATED_ATTRIBUTE typedef enum Image::Format tImageFormat; #define kCCTransitionOrientationLeftOver kTransitionOrientationLeftOver #define kCCTransitionOrientationRightOver kTransitionOrientationRightOver diff --git a/cocos2dx/misc_nodes/CCRenderTexture.cpp b/cocos2dx/misc_nodes/CCRenderTexture.cpp index d76bfafa48..0cd36c65a0 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.cpp +++ b/cocos2dx/misc_nodes/CCRenderTexture.cpp @@ -550,16 +550,16 @@ bool RenderTexture::saveToFile(const char *szFilePath) Image *pImage = newImage(true); if (pImage) { - bRet = pImage->saveToFile(szFilePath, kImageFormatJPEG); + bRet = pImage->saveToFile(szFilePath, Image::FORMAT_JPG); } CC_SAFE_DELETE(pImage); return bRet; } -bool RenderTexture::saveToFile(const char *fileName, tImageFormat format) +bool RenderTexture::saveToFile(const char *fileName, Image::Format format) { bool bRet = false; - CCASSERT(format == kImageFormatJPEG || format == kImageFormatPNG, + CCASSERT(format == Image::FORMAT_JPG || format == Image::FORMAT_PNG, "the image can only be saved as JPG or PNG format"); Image *pImage = newImage(true); diff --git a/cocos2dx/misc_nodes/CCRenderTexture.h b/cocos2dx/misc_nodes/CCRenderTexture.h index a2b0fcca2d..0dd623186a 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.h +++ b/cocos2dx/misc_nodes/CCRenderTexture.h @@ -28,6 +28,7 @@ THE SOFTWARE. #include "base_nodes/CCNode.h" #include "sprite_nodes/CCSprite.h" #include "kazmath/mat4.h" +#include "platform/CCImage.h" NS_CC_BEGIN @@ -36,11 +37,6 @@ NS_CC_BEGIN * @{ */ -typedef enum eImageFormat -{ - kImageFormatJPEG = 0, - kImageFormatPNG = 1, -} tImageFormat; /** @brief RenderTexture is a generic rendering target. To render things into it, simply construct a render target, call begin on it, call visit on any cocos @@ -117,7 +113,7 @@ public: /** saves the texture into a file. The format could be JPG or PNG. The file will be saved in the Documents folder. Returns YES if the operation is successful. */ - bool saveToFile(const char *name, tImageFormat format); + bool saveToFile(const char *name, Image::Format format); /** Listen "come to background" message, and save render texture. It only has effect on Android. diff --git a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp index 0e3499d128..9fc5b77efc 100644 --- a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp +++ b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp @@ -147,8 +147,8 @@ void RenderTextureSave::saveImage(cocos2d::Object *pSender) char jpg[20]; sprintf(jpg, "image-%d.jpg", counter); - _target->saveToFile(png, kImageFormatPNG); - _target->saveToFile(jpg, kImageFormatJPEG); + _target->saveToFile(png, Image::FORMAT_PNG); + _target->saveToFile(jpg, Image::FORMAT_JPG); Image *pImage = _target->newImage();