//-----------------------------------------------------------------------------
// Name: void LoadImage()
// Desc: Loads Image onto a SDL Surface
//-----------------------------------------------------------------------------
void SDLSPRITE::LoadImage( const char *ImageFilePath, bool ColorKey, int Red, int Green, int Blue )
{
// Create a temporary surface to load in image
SDL_Surface *TempSurface = NULL;
// Load in the image to a sdl software surface
if( ( TempSurface = IMG_Load( ImageFilePath ) ) == NULL)
{
programlog( "\nCouldn't Load Image: %s ", ImageFilePath );
EndProgram();
}
// Set the color key for the transparent color if there is one
if(ColorKey)
SDL_SetColorKey( TempSurface, SDL_SRCCOLORKEY, SDL_MapRGB( TempSurface->format, Red, Green, Blue ) );
// Now create a hardware surface to use with the image
ImageSurface[ m_ImageCount ] = SDL_DisplayFormat( TempSurface );
// Finished with the temporary sprite so release it
SDL_FreeSurface( TempSurface );
// Null the surface
TempSurface = NULL;
// Increment the text count everytime through the loop to keep a total of the images loaded
m_ImageCount++;
}