# FreeImage Can't Load PNGs for iOS

This topic is 2153 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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

• 13
• 18
• 29
• 11
• 27