CCImage getData() RGBA infos , Android

Hi Community,

I am porting a game i did for iOS using cocos2d-iphone to Android.

I need to extract the RGBA ( alpha channel inclusive ) pixel information from an Image stored in the Resources folder, i use the following code:

// Extract pixel information from Image
CCImage *image = new CCImage();
image~~>initWithImageFile;
unsigned char*layerPixels = image~~>getData();
int length = strlen((char*)layerPixels);

The problem is that the length of the layerPixels variable is width*height*3 , meaning RGB information, but i also need the alpha channel information.

Do you know how to do it? i am using cocos2d-1.0.1-x-0.13.0-beta

Thanks in advance.

Is it a jpeg image? If so, you need to make up alpha channel manually.
You can use CCImage::hasAlpha method to find out whether the image has an alpha channel.