Hi, (sorry for my english)
I need to convert one surface (32bpp) to another (24bpp), so the new surface has
only RGB components. I think that the function for this job is
SDL_ConvertSurface(SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags) but it
seems I’m doing something wrong. I’m not sure what values should I set to the
new format.
Thanks for any help.
Bedrich Michalek
Bedrich Michalek wrote:
Hi, (sorry for my english)
I need to convert one surface (32bpp) to another (24bpp), so the new surface has
only RGB components. I think that the function for this job is
SDL_ConvertSurface(SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags) but it
seems I’m doing something wrong. I’m not sure what values should I set to the
new format.
Thanks for any help.
Two solutions :
- you can fill the SDL_PixelFormat structure directly (see the man page
for SDL_PixelFormat) but this pixel format has to match the destination
surface format.
- you create a new surface of the right format with SDL_CreateRGBSurface
and then do a blit to it :
destination = SDL_CreateRGBSurface(flags, width, height, 24, 0x000000ff,
0x0000ff00, 0x00ff0000, 0x00000000);
SDL_BlitSurface(source, NULL, destination, NULL);
Stephane