Need SDL_SetColorKey help

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 :wink:
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

You have to set transparent in the source image(s), not the destination.

ttfn,
JohnOn Wed, Sep 29, 1999 at 07:38:11PM +0200, patouet wrote:

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 :wink:

Thank’s, it works better ;-)On 30 Sep 99, at 11:04, John Marshall wrote:

On Wed, Sep 29, 1999 at 07:38:11PM +0200, patouet wrote:
You have to set transparent in the source image(s), not the destination.

ttfn,
John