Do you mean the surface’s Amask? Yeah, it works. That’s just part of the
description of the pixel representation. The surface will store this info
and an extra byte (for 32-bit pngs) per pixel to store the alpha at that
pixel. What are you trying to do?
Jonny D
i have some pngs where in gimp i already set the background as transparent
for a flash game, which loads the images with the transparent bits, there
are ways to set transparency after you loaded but its a pain, anyways, so i
have all the images and all i really want to do is load them as they appear
in gimp with all their transparent bits intact.
my image loading function looks like this ( i only use png’s )
SDL_Surface *getimage(int alpha, int mask, char *name)
{
SDL_Surface *surface;
char path[256];
char msg[256];
strcpy(path, DATA_PREFIX);
strcat(path, "gfx/");
strcat(path, name);
strcat(path, ".png");
surface = IMG_Load(path);
if (surface == NULL)
{
strcpy(msg, path);
strcat(msg, " Not Loaded");
debug(msg,0);
}
else
{
SDL_Surface *image;
if (mask==0) SDL_SetColorKey(surface, SDL_SRCCOLORKEY,
SDL_MapRGB(surface->format, 0, 0, 0));
if (mask==1) SDL_SetColorKey(surface, SDL_SRCCOLORKEY,
SDL_MapRGB(surface->format, 255, 255, 255));
image = SDL_DisplayFormat(surface);
SDL_FreeSurface(surface);
strcpy(msg, path);
strcat(msg, " Loaded");
debug(msg,0);
if (alpha>-1) SDL_SetAlpha(image, SDL_SRCALPHA, alpha);
return image;
}
return 0;
}
i just actually got to the part of loading and plotting and i set them to
have mask black, which works on the un-previously edited ones, pngs seem to
be able to remember what was underneath the transparency so some images work
fine with black set and some still have remnants of previous editing, but it
would still be nice to be able to know how to load pngs with proper alpha so
certain parts of the images are semi transparent etc.
Thanks!On 2 July 2010 12:57, Jonathan Dearborn wrote: