CCSprite to UIImage

CCSprite to UIImage
0.0 0


Hi, I’m having some trouble trying to convert a CCSprite to a UIIMage, any one could help me please?


CCSprite is a c*+ class, and UIImage is a ojective-c class.
How can you convert a c*+ class to a objective-c class?


When i said convert, I mean get an uiimage from a ccsprite :).

Actually Im trying to save a CCSprite mixed with a UIImage into the iPhone photo library. Which will be the best way to achieve this?? is it possible?
Thanks for answering


Did you want to save a CCSprite as a picture, such as xxx.png?
If so, you can refer test case of RenderTextureSave in tests/tests/RenderTextureTest/RenderTextureTest.cpp.
You can draw the sprite into the texture, then save it as a file.


Hi, Jon Lopez, the png/jpg data is converted to into opengl texture in CCTexture2D::initWithData(…),
So I think you cannot get the image raw data from CCSprite to make your UIImage.
Of course you can hack the source, and save a memory copy of *data in CCTexture2D::initWithData


Hi both and really thanks for your fast response, finally I made it possible by taking and screenshot of the openglView with my sprite on it, its enough for me so there is no need to hack the source.

Once again thanks for responding, and of course if anyone needs to do the same and needs the source just ask me for it.


i know I’m so late…
but If you don’t mind, can I get the source?