I’m trying to create a sprite with an image picked from gallery. The code works for iOS, but I get a black sprite in Android.
The image from gallery is saved into the “app dir”. This is the Java code:
Bitmap original = BitmapFactory.decodeFile(selectedImageFromGalleryPath);
String pngPath = myActivity.getFilesDir() + “/” + imageName + “.png”; // Absolute path
FileOutputStream stream = new FileOutputStream(pngPath);
Bitmap resizedBitmap = Bitmap.createScaledBitmap(original, newWidth, newHeight, false);
The absolute path is passed to a native cpp code to create the sprite:
CCSprite *s = CCSprite::create(pngPath);
The result is a black sprite. I have debugged the CCTextureCache and seems that the image is found ok in:
bool bRet = pImage->initWithImageFile(fullpath.c_str(), eImageFormat);
but displays a BLACK image!!!