[SDL] Alpha + colorkey

Clemens Kirchgatterer clemens at 1541.org
Thu Oct 13 22:50:32 PDT 2005


Albert Fernández Marsal <afmarsal at cirsa.com> wrote:

> I have a PNG image (with per pixel alpha) and I want to blit it on a
> surface with colorkey (at first, without alpha). The image has all
> over the edge some transparent pixels so it displays at its own as a
> "rounded" surface. The problem comes when I try to blit it over a
> surface with colorkey set. This surface should be fully transparent
> (it's a surface made of a single color, and that color is the
> colorkey), but when I make the blit from the image to the transparent
> surface, all over the "new image", where the pixels where transparent
> at first, now I see the colorkey of the transparent surface!

this is to be expected. the alpha pixels alter the "first colorkey
colored" pixels of the destination surface slightly, so they do not
match the colorkey anymore. you can check this by reading the pixel
values after the blit using get_pixel() (from the SDL docs).

there is nothing you can do about this. but why do you want to blit an
alpha channeled surface to a surface filled with the colorkey in the
first place?

clemens



More information about the SDL mailing list