This project is read-only.

Screenshot

Topics: Saving Files and Data
Mar 28, 2014 at 2:36 PM
Hi all,

I would like to save a CCColorLayer as a png on Android and iOS. The layer contains a CCSprite and a CCRenderTexture.
With CCRenderTexture in Monogame it's not possible to get the png with saveAsPng() for Android and iOS.
And I don't seem to find the way to work with glReadPixels in C#.

Is there anyone who tried this already an has an example of how to do it?
Or are there any other suggestions?

Thanks in advance,
Glen
Mar 28, 2014 at 4:25 PM
Change the manner in which you display the layer.

Use the CCRenderTexture to render the entire scene, then pull out the texture and save it. You can find a sample of this in the tests:

https://github.com/Cocos2DXNA/cocos2d-xna/blob/master/tests/tests/classes/tests/RenderTextureTest/RenderTextureSave.cs
Mar 31, 2014 at 12:27 PM
As far as I can see this only works on Windows.

The function SaveAsPng() is not implemented for Texture2d for Android and iOS.

Or am I missing an update?
Apr 4, 2014 at 1:07 AM
They will come soon - MonoGame is working on adding a light weight PNG library. When that happens then we'll get PNG support across the platforms.

The iOS side should work. I am surprised it does not have a CG version of PNG writing....