CCImage->getData() does not work on Android, but works on iOS. I am using 2.2.0 version

CCImage->getData() does not work on Android, but works on iOS. I am using 2.2.0 version

The app crashes.

#17 pc 001cb9b7 /data/app-lib/com.abitalk.alphabetplus-1/libalphabetplus.so (Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeRender+10)

I/DEBUG ( 1752): #00 pc 0014bfae /data/app-lib/com.abitalk.alphabetplus-1/libalphabetplus.so (PView::do_fill(cocos2d::CCPoint, c3b)+81)
I/DEBUG ( 1752): #01 pc 0014c233 /data/app-lib/com.abitalk.alphabetplus-1/libalphabetplus.so (PView::ccTouchesBegan(cocos2d::CCSet**, cocos2d::CCEvent**)+62)
I/DEBUG ( 1752): #02 pc 001e51c3 /data/app-lib/com.abitalk.alphabetplus-1/libalphabetplus.so (cocos2d::CCTouchDispatcher::touches(cocos2d::CCSet**, cocos2d::CCEvent**, unsigned int)+446)
I/DEBUG ( 1752): #03 pc 001e5347 /data/app-lib/com.abitalk.alphabetplus-1/libalphabetplus.so (cocos2d::CCTouchDispatcher::touchesBegan(cocos2d::CCSet**, cocos2d::CCEvent**)+14)
I/DEBUG ( 1752): #04 pc 001c90c3 /data/app-lib/com.abitalk.alphabetplus-1/libalphabetplus.so (cocos2d::CCEGLViewProtocol::handleTouchesBegin(int, int**, float**, float*)+346)
I/DEBUG ( 1752): #05 pc 001cbde7 /data/app-lib/com.abitalk.alphabetplus-1/libalphabetplus.so (Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesBegin+26)
I/DEBUG ( 1752): 60906b3c 615929eb /data/app-lib/com.abitalk.alphabetplus-1/libalphabetplus.so (cocos2d::CCNode::boundingBox()+46)
I/DEBUG ( 1752): 60906ba4 615d41c5 /data/app-lib/com.abitalk.alphabetplus-1/libalphabetplus.so (cocos2d::CCTouchDispatcher::touches(cocos2d::CCSet**, cocos2d::CCEvent**, unsigned int)+448)

here is the error message.

I use CCImage to load a png file and test the CCImage->getData(), it works ok on my computer. Could you please discribe it more specificly? Like what kind of image file you loaded, where and how you use it. Thank you!

I need to get the raw data from my png file. I attached the file here. It is a coloring app. I need the raw data to modify the bytes of the image.

static UInt8 pixdata;
static UInt32 pixsize;
CCImage
img = new CCImage();
img~~>initWithImageFile;
int alp = 3;
if) {
CCLOG (“has Alpha”);
alp = 4;
}
pixsize = alp * img~~>getDataLen();
pixdata = new unsigned char[pixsize];
pixdata = img->getData(); //HERE IS THE PROBLEM on android. It works ok on iOS

Any progress with this? I am having almost the same problem, on Android. In my case, the app does not crash, but the pixel data is not complete. I think the function CCImage::getDataLen() is returning the wrong value too.

For example, my image is 50x50 pixels. If I call getDataLen() on the image after loading it returns 2500 which is incorrect - it should be 10000 (because RGBA8888 should be 4 * 50 * 50).

I can access the pixel data, but only up to the position given by getDataLen(), and it seems like the data only contains every 4th pixel.

Okay, I have seen from other posts here that the getDataLen() function just returns the number of pixels!

But we can already get the number of pixels using getWidth() and getHeight().

The term ‘data length’ usually means a number bytes, and even the CCImage header uses it like that everywhere else. Very confusing.

Also, when you have a function called getData(), then a companion function called getDataLen() should return the length of that data (bytes!), not some other length.