Hello,
I’m trying to use the SDL_SetColorKey function.
I drawn a BMP image in 24bits. After, I drawn another BMPs on it but
with a
transparent color (0x00FF00). But sprites are drawn with the green
color.
Someone could help a poor french guy
This is the code:
void showBMP(char *file, SDL_Surface *screen, int x, int y, int
transparence)
{
SDL_Surface *image, *surf_tmp;
SDL_Rect dest;
/* Load the BMP file into a surface */
image = SDL_LoadBMP(file);
if ( image == NULL ) {
fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
return;
}
if(transparence==YES)
SDL_SetColorKey(screen, SDL_SRCCOLORKEY, 0x0000FF00);
/* Blit onto the screen surface.
The surfaces should not be locked at this point.
*/
dest.x = x;
dest.y = y;
dest.w = image->w;
dest.h = image->h;
surf_tmp = SDL_DisplayFormat(image); /* I've try other solutions */
SDL_BlitSurface(surf_tmp, NULL, screen, &dest);
/* Update the changed portion of the screen */
SDL_UpdateRects(screen, 1, &dest);
}
At least someone could tell me where I can find a “tutorial” (or
similar).
Thank’s