Jump to content
  • Advertisement
Sign in to follow this  
matrisking

[Resolved] IMG_Load won't load a PNG

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!