All pastes #90393 Raw Edit

Mirchiss

public cpp v1 · immutable
#90393 ·published 2006-07-17 17:11 UTC
rendered paste body
SDL_Surface *load_image( char filename [50] ) {    //Temporary storage for the image that's loaded    SDL_Surface* loadedImage = NULL;        //The optimized image that will be used    SDL_Surface* optimizedImage = NULL;        //Load the image    loadedImage = SDL_LoadBMP( filename );        //If nothing went wrong in loading the image    if( loadedImage != NULL )    {        //Create an optimized image        optimizedImage = SDL_DisplayFormat( loadedImage );                //Free the old image        SDL_FreeSurface( loadedImage );                //Map the color key            Uint32 colorkey = SDL_MapRGB( optimizedImage->format, 255, 255, 255 );                        //Set all pixels of color R 0, G 0xFF, B 0xFF to be transparent            SDL_SetColorKey( optimizedImage, SDL_RLEACCEL | SDL_SRCCOLORKEY, colorkey );    }    //Return the optimized image    return optimizedImage;}