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

Recommended Posts

Hi, I worked through a number of lazy_foo's SDL tutorials and have wrote some code based on them. However, I'm having difficulty with the IMG_Load function that's part of SDL_image. It displays .bmp files without any issues, but when I try to load a .png file, nothing happens. In the following two lines: loadedImage = IMG_Load( tempFileName.c_str() ); if ( loadedImage != NULL ) loadedImage is NULL after the assignment whenever I use a png file. I thought the whole point of IMG_Load was that it could handle multiple image file types. Am I missing something? Is there more code I could paste to shed more light on the issue? Thanks! [Edited by - matrisking on April 27, 2010 9:02:30 AM]

Share on other sites
Did you try following the code through to where it checks if different image types are enabled? I had this problem before... and the documentation doesn't talk much about it, so I'm guessing you are having the same problem I ran into a long time ago.

Open up SDL_image.h. At the top is the following code:

#ifndef _SDL_IMAGE_H#define _SDL_IMAGE_H#define LOAD_BMP

Add in #define LOAD_PNG to make it like this

#ifndef _SDL_IMAGE_H#define _SDL_IMAGE_H#define LOAD_BMP#define LOAD_PNG

Each file type that SDL_Image loads has a different value that needs to be defined. Look through the code to find them.

Share on other sites
I thought that was only the case if you built the library yourself. If not, make sure you have the relevant 2 extra DLLs - libpng and zlib, I believe.

Share on other sites
That did the trick, I forgot all about those.

Thanks!

• 40
• 12
• 10
• 10
• 9
• Forum Statistics

• Total Topics
631371
• Total Posts
2999611
×