Android PNG problems

Android PNG problems
0.0 0


My app uses a lot of PNG textures that in total take up more than 20MB. I used the tool “ImageOptim” (which internally just calls pngout and pngcrush) to make the files smaller. The new textures work well on iPhone, but on Android many of them either cause a crash or display with “bands”, white lines running across the texture.

The possible causes I can think of are:

  • Android aapt is compressing the images again and causing the problem.
  • pngcrush or pngout are removing important headers that are required by libpng but not by iOS.

Are any of these solutions possible?

  • Is there a way to read images from res/raw in cocos2d-x? This would avoid the re-compression.
  • Can I load a PNG image from a file with a different extension, like MP3? This would avoid the re-compression too.
  • Is there a way to manually specify the width and height of a PNG image when loading it, rather than attempting to read the headers as CCImageCommon_cpp.h does? Most of my textures are of a known POT size.




I noticed in the CHANGELOG:

Bug #1403: fix a bug that do not support png8 format

Could this be a possible resolution to my issue? I had just upgraded to 2.01 for the Android project and found it a real PITA, creating a new project, setting up Eclipse C++, makefile etc. etc. But if that resolves it, I’ll give it a shot. I can’t find this issue in the Issues section of this website though; can anyone tell me which files were modified?