[SDL] Sorry to bother you

James Barrett xucaen at gmail.com
Sun Dec 23 09:52:06 PST 2007



mads jørgensen wrote:
> SDL_Surface *load_image( 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 )           
>         {
>           SDL_SetColorKey( loadedImage, SDL_SRCCOLORKEY, SDL_MapRGB(
> loadedImage->format, 255, 0, 255 ) );
>             //Create an optimized surface
>             optimizedImage = SDL_DisplayFormatAlpha( loadedImage );
>                
>             //Free the old surface
>             SDL_FreeSurface( loadedImage );
>            
>           
>            
>         }
>         //Return the optimized surface
>         return optimizedImage;
>     }

What happens if you call SDL_DisplayFormat() instead of
SDL_DisplayFormatAlpha()? I think SDL_DisplayFormatAlpha() is only used
if you are using an alpha channel.


Jim



More information about the SDL mailing list