Sign in to follow this  
MikaHell

SDL_Load_RW problem

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

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