Jump to content
  • Advertisement
Sign in to follow this  
MikaHell

SDL_Load_RW problem

This topic is 3855 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'm having strange problems with SDL image loading from resource files. I've been trying to load bmp and png files, but I can't make it to work. Here is the piece of code where I get errors: SDL_RWops *rw = SDL_RWFromMem(data, filesize); bool isPNG = IMG_isPNG(rw); SDL_Surface *surface = IMG_LoadPNG_RW(rw); The surface pointer always gets set to NULL, though the function "IMG_isPNG" returns true... I don't understand that my resource pointer is REALLY a png and that it can't be loaded with the "IMG_LoadPNG_RW" function. I am using MSVC++ 2005, and I have included the following, so I don't suppose I am missing something: #include "SDL/SDL.h" #include "SDL/SDL_main.h" #include "SDL/SDL_image.h" #pragma comment (lib, "SDL/SDL.lib") #pragma comment (lib, "SDL/SDLmain.lib") #pragma comment (lib, "SDL/SDL_image.lib") Also, using a bmp resource, I get more error as IMG_isBMP returns false... Thanks

Share this post


Link to post
Share on other sites
Advertisement
Sorry, I forgot to tell! It says "Error reading the PNG file". Then I tried also simply with "IMG_Load_RW", and it said that the file format isn't supported.
Even though "IMG_isPNG" returns true. Maybe that function simply checks if the file's extension is .png? But my png file isn't corrupted, as I can open it with "IMG_Load()".

I also found a similar case here:
http://www.gamedev.net/community/forums/topic.asp?topic_id=302474

[Edited by - MikaHell on December 30, 2007 6:51:47 PM]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!