// ============== Loading Code =================
SDL_Surface *setTransparent(SDL_Surface sprite)
{
/ Set transparent pixel as the pixel at (0,0) */
if (sprite->format->palette ) {
SDL_SetColorKey(sprite, (SDL_SRCCOLORKEY|SDL_RLEACCEL),
*(Uint8 *)sprite->pixels);
}
return sprite;
}
SDL_Surface *loadImage(char *file_name)
{
SDL_Surface *image, *newImage;
/* Load the BMP file into a surface */
image = IMG_Load(file_name);
//image = SDL_DisplayFormat(screen);
if (image == NULL) {
fprintf(stderr, "Couldn't load %s: %s\n", file_name,
SDL_GetError());
exit(1);
}
newImage = SDL_DisplayFormat(image);
SDL_FreeSurface(image);
return setTransparent(newImage);
}
// ============== Blitting Code ================
void blit(SDL_Surface *image, int x, int y)
{
// Set up a rectangle to draw to
SDL_Rect area;
area.x = x;
area.y = y;
area.w = image->w;
area.h = image->h;
/* Blit onto the screen surface */
if(SDL_BlitSurface(image, NULL, globals.screen, &area) < 0)
fprintf(stderr, "BlitSurface error: %s\n",
SDL_GetError());
//SDL_UpdateRect(screen, x, y, image->w, image->h);
}> -----Original Message-----
From: Steven James Stapleton [SMTP:stapleton.41 at osu.edu]
Sent: Monday, April 22, 2002 12:16 PM
To: sdl at libsdl.org
Subject: Re: [SDL] Transparency on 16bit screens
could you show us your loading/blitting code?
-Jim
----- Original Message -----
From: “Sweeney, Steven (FNB)”
To:
Sent: Monday, April 22, 2002 6:39 AM
Subject: [SDL] Transparency on 16bit screens
I’ve just upped the color depth of my game from 8bit to 16bit to allow
for
some better backgrounds. Only problem is tht I have now lost the
transparency of the sprites and everything else. All the images now have
their black background surrounding them.
It happens for images that are 4bit (16 color BMPs) or PNG/JPG/GIF
images.
Any suggestions?
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl