Jump to content
  • Advertisement
Sign in to follow this  

image doesnt load.

This topic is 3593 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

hello guys. i am been following lazy foo's tutorials at SDL on C++ there is a problem, lesson number 7 and 8 doesnt load the image, i did the debug, and the image doesnt load at

SDL_Surface *load_image( std::string filename ) 
    //The image that's loaded
    SDL_Surface* loadedImage = NULL;
    //The optimized surface that will be used
    SDL_Surface* optimizedImage = NULL;
    //Load the image
    loadedImage = IMG_Load( filename.c_str() );
    //If the image loaded
    if( loadedImage != NULL )
        //Create an optimized surface
        optimizedImage = SDL_DisplayFormat( loadedImage );
        //Free the old surface
        SDL_FreeSurface( loadedImage );
        //If the surface was optimized
        if( optimizedImage != NULL )
            //Color key surface
            SDL_SetColorKey( optimizedImage, SDL_SRCCOLORKEY, SDL_MapRGB( optimizedImage->format, 0, 0xFF, 0xFF ) );
    //Return the optimized surface
    return optimizedImage;

i have everything right on link, dll's and stuff, but i dont know why it doesnt load :S is there something that i am not watching?

Share this post

Link to post
Share on other sites
did you debug it ?

do you know where it's not working ?

try ouputing the error with SDL_GetError() to see what isn't working.

hope that helps !

Share this post

Link to post
Share on other sites
If IMG_Load returns NULL, use IMG_GetError to get a human readable string describing the problem. The usual suspects are:

1) File doesn't exist or has a different name (check on filesystem)
2) File exists, but path is incorrect (try using an absolute path)
3) File has wrong format (E.G. without libpng.dll PNG files will not load)

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!