First off make sure that the image is in a small file type format like "PNG". Second when blitting the image make sure that you are not adding the transparency color to the background image is it is pointless and takes up a LOT of cpu cycles. Here's an example of code I've written a long time ago as a wrapper for image loading
SDL_Surface* altSDL::load_image(std::string filename)
{
SDL_Surface* loadedImage = NULL;
SDL_Surface* optimizedImage = NULL;
loadedImage = IMG_Load( filename.c_str() );
if( loadedImage != NULL )
{
optimizedImage = SDL_DisplayFormat( loadedImage );
SDL_FreeSurface( loadedImage );
}
else
{
Failure* fail;
fail = Failure::getInstance();
fail->failLog(filename);
}
if( optimizedImage != NULL )
{
Uint32 colorkey = SDL_MapRGB( optimizedImage->format, 0xFF, 0, 0xFF );
SDL_SetColorKey( optimizedImage, SDL_SRCCOLORKEY, colorkey );
}
return optimizedImage;
}
In this code you will be able to pass all your images into this to be optimized very seamlessly, but in the case of background/Large images you would need to make sure that this last block of code is changed to something more along the lines of something like this:
//Added some Sudo code
if( loadedImage != NULL && !isBigImage)
{
optimizedImage = SDL_DisplayFormat( loadedImage );
SDL_FreeSurface( loadedImage );
}
else if(!isBigImage)
{
Failure* fail;
fail = Failure::getInstance();
fail->failLog(filename);
}
the isBigImage is the sudo code i added and is a parameter passed in; in certain cases.This will make all your images optimized, smaller(Should make sure they are png files) and will make it so the transparency is only added to small image files so your background does not solw your fps