Sign in to follow this  
Vincent_M

FreeImage Can't Load PNGs for iOS

Recommended Posts

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.

Edited by Vincent_M

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this