Newbie q: display format

dear all,

in a piece of code, i saw something like:

bmpimage1 = SDL_LoadBMP(“bed.bmp”);
/* Convert to display format */
image1 = SDL_DisplayFormat(bmpimage1);

i don’t understand what the api reference says about SDL_DisplayFormat.
what exactly does this function do? i can use SDL_BlitSurface just fine on
both bmpimage1 and image1. why does it need to be converted?

what is the difference between these two surfaces?

thanks!
pete

Peter Jay Salzman wrote:

dear all,

in a piece of code, i saw something like:

bmpimage1 = SDL_LoadBMP(“bed.bmp”);
/* Convert to display format */
image1 = SDL_DisplayFormat(bmpimage1);

i don’t understand what the api reference says about SDL_DisplayFormat.
what exactly does this function do? i can use SDL_BlitSurface just fine on
both bmpimage1 and image1. why does it need to be converted?

what is the difference between these two surfaces?

thanks!
pete

The difference is that the original bed.bmp is loaded from a bitmap which is a
32-bit RGBA (or maybe a 24-bit RGB aligned to 32 bits?), whereas your display
may be running at 8, 16, 24, 32 or however many bits/pixel :slight_smile: The SDL blit
functions will autoconvert, but if they’re the same pixel depth, which is
quickly done with the SDL_DisplayFormat() call, they blit faster since they
don’t need to be converted – it’s a convenient optimization.–

Kendall E. Blake
kendallemm at hotmail.com

    You will remember, Watson, how the dreadful business of the

Abernetty family was first brought to my notice by the depth which the
parsley had sunk into the butter upon a hot day.
– Sherlock Holmes