Why do I need this?
Basically I need to turn a color image into gray-scale. Including a gray-scale version of the image could be a solution, but space is tight in my situation - I don't want my APK to be too big. Besides, I would like to work on the pixels for some effects too. Again, this is to make the APK smaller.
I have found getPixel setPixel from CCTexture2D and Getting image's pixel RGBA, but I would like something more simple.
Any help is appreciated.
Thank you!
This can be done a couple of ways. What I have done in the past is to just called setColor on the sprite to some color close to what you are looking for. That had worked for my purposes.
my_sprite.setColor( ccc3( 128, 128, 128 ) );
Another solution (more thorough and precise): how to implement grayscale rendering in OpenGL?
Here is my solution for you :
1.First make a CCImage version of your image:
I) from File :
II) From Sprite :
II.1) CCSprite -> RenderTexture2D
II.2) RenderTexture2D -> CCImage (
CCImage *testImage = RenderText2D->newCCImage();
)2.Then You can do what you need :
3.Then, convert it to texture_2D
4.And Finally back to CCSprite