Why did you use 1024*1024 ? Use the size the same as your screen pixel size will be better. Otherwise, the saved image outside the screen size will be the color you clear.
I don’t think so. If the background color is yellow, the alpha value of your image is 0, it means that the image will not be shown, but the dumped png will contain the background color.
Thanks a lot for your reply. … so the alpha value is useful when blending this texture with other sprites ? . What i wanted to accomplish was to generate a sprite sheet from within cocos2d-x itself. My approach was arrange all the images to be packed on a sprite. Render the arranged sprite on a texture using CCRenderTexture , then dump the texture . The problem is that the images with transparency are getting filled with the background color of the CCRenderTexture.
Hi, i was this problem to, i’m solved:
in method CCRenderTexture::saveToFile, change
bRet = pImage~~>saveToFile, true); // if true save only RGB
//new line
bRet = pImage~~>saveToFile(fullpath.c_str(), false);// save all pixels component RGBA
I met the same problem. I combined two texture into one and tried to export as an png file with transparency. however, render->saveToFile("pic.png", kCCImageFormatPNG); also exports the backgournd color
render~~>saveToFile;
because kCCImageFormatPNG force bIsRGB = true
but PNG with alpha must have 32 bit. Attention, because this method wants path and not file name
this is a criptic code for me, and I have a problem too.
I’m working on it now, but when I try to load saved RenderTexture in a new RenderTexture, I saw a strange effect on the border of my image.
as if the border, which is nuanced, lose this nuance
Simple code for me
// SAVE
@
std::stringstream path; @
@ path << CCFileUtils::sharedFileUtils~~>getWritablePath;@
@ path << “DrawingTexture.png”;@
@ renderTexture~~>saveToFile.c_str);@
@ renderTexture~~>clear(0, 0, 0, 0);
@