[SDL] LoadIMG

Ivan Stankovic pokemon at fly.srk.fer.hr
Sat May 10 02:39:01 PDT 2003


On Sat, May 10, 2003 at 11:01:13AM +0300, Hri wrote:
> 
>  // Set display format for fast blitting
>  ready = SDL_DisplayFormat( temp );
>  if( ready == NULL )
>  {
>   printf( "Image display format conversion failed: %s\n",
>        SDL_GetError()
>      );
>   exit( 3 );
>  }
> 
>  return ready;
> }

You should free the temp surface before you return, because SDL_DisplayFormat()
creates a new surface. You may also consider using the temp surface if converting
fails (yes, it will be slower, but...), something like this:

	ready = SDL_DisplayFormat(temp);
	if(ready)
		SDL_FreeSurface(temp);
	else
		ready = tmp;
	
	return ready;

BTW, does anyone know in which cases will SDL_DisplayFormat actually fail?

-- 
Ivan Stankovic, pokemon at fly.srk.fer.hr




More information about the SDL mailing list