Jump to navigation Jump to search
1,369 bytes added ,  16:17, 13 May 2009
Thanks, [[User:GabberNL|GabberNL]] 14:25, 28 April 2009 (UTC)
I used this function:
<source lang="cpp">
SDL_Surface *load_image( std::string filename )
//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.c_str() );
//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 );
//Return optimized image
return optimizedImage;
And applied the loaded image to a new surface with this function:
<source lang="cpp">
void apply_surface ( int x, int y, SDL_Surface* source, SDL_Surface* destination )
//Make a temporary rectangle to hold the offsets
SDL_Rect offset;
//Give the offsets tot the rectangle
offset.x = x;
offset.y = y;
//Blit the surface
SDL_BlitSurface( source, NULL, destination, &offset );
But when i try to compile it it sais it doesnt have the length of the image. Can somebody help me?
[[User:GabberNL|GabberNL]] 14:17, 13 May 2009 (UTC)
== __static_initialization_and_destruction_0 error ==


Navigation menu