FreeImage Can't Load PNGs for iOS

Started by
-1 comments, last by Vincent_M 10 years, 7 months ago

For some reason, FreeImage can't load PNGs from my bundle for iOS. Here's the part that fails:


// 'fullPath' is a valid path leading to my PNG
fif = FreeImage_GetFileType(fullPath, 0);
if(fif == FIF_UNKNOWN) fif = FreeImage_GetFIFFromFilename(fullPath);
if(fif == FIF_UNKNOWN)
{
	printf("TextureData::TextureData(%s): could not resolve file type\n", filename);
	return;
}

This is actually code that's contained in my image loader class. It loads PNGs on Android and Mac just fine. It even loads the JPG version of my image from iOS. I know the filename and path are correct because I'll attempt to open the PNG from fullPath using a file pointer, and it comes back valid.

My theory is that because PNGs store the image data using zlib's deflate algorithm, it tries running it, but it's probably reading the data directly from the bundle, which is already inside of a zipped archive. Then again, the PNG loads just fine doing the exact same thing from it's archived bundle.

EDIT: I believe I found my answer after some more searching. It turns out that Xcode will try to compress PNGs by default. You'll need to go into your project's build settings, and do a search for PNG. You'll get a result called Compress PNG Files, which needs to be set to No.

This topic is closed to new replies.

Advertisement