[despammed] Bliting, alpha channel, anti-alliasing

Adilson Oliveira wrote:

Hi.

I’m developping an apication and the sprites I have to use has an
anti-aliasing effect. When I blit them on the background surface, I got
an ugly border because of the transparecy.
Any ideias how to have transparency on anti-aliased images? Is an alpha
channel the solution? If so, how?

Just a guess, but is the anti-alias by any chance against black background?
That won’t work because the transparency blends against the non-black background thus
you get the black border in the anti-aliased edge pixels.

The solution is actually to not have any anti-alias at the edges, but only use
edge-transparency => alpha channel!
Then it will anti-alias nicely against any background, and also any overall
transparency you might use will work as well.

I hope I managed to explain that in somewhat understandable terms…

/Andr?

Tatsujin wrote:

Adilson Oliveira wrote:

Hi.

I’m developping an apication and the sprites I have to use has an
anti-aliasing effect. When I blit them on the background surface, I
got an ugly border because of the transparecy.
Any ideias how to have transparency on anti-aliased images? Is an
alpha channel the solution? If so, how?

Just a guess, but is the anti-alias by any chance against black background?

You’re right. It’s black

That won’t work because the transparency blends against the non-black
background thus you get the black border in the anti-aliased edge pixels.

The solution is actually to not have any anti-alias at the edges, but
only use edge-transparency => alpha channel!
Then it will anti-alias nicely against any background, and also any
overall transparency you might use will work as well.

I hope I managed to explain that in somewhat understandable terms…

Hmmm… unfortunatly not :wink:
Sorry but I’m starting on this subject. Can you explain further,
specialy this part:

The solution is actually to not have any anti-alias at the edges, but
only use edge-transparency => alpha channel!
How do I do that? I understand the images must not have an anti-alias
but I completly missed the 2nd part.

TIA

Adilson.

Tatsujin wrote:

Adilson Oliveira wrote:

Hi.

I’m developping an apication and the sprites I have to use has an
anti-aliasing effect. When I blit them on the background surface, I
got an ugly border because of the transparecy.
Any ideias how to have transparency on anti-aliased images? Is an
alpha channel the solution? If so, how?

Just a guess, but is the anti-alias by any chance against black background?

You’re right. It’s black

The thing to keep in mind is that black is zero…

That won’t work because the transparency blends against the non-black
background thus you get the black border in the anti-aliased edge pixels.

The solution is actually to not have any anti-alias at the edges, but
only use edge-transparency => alpha channel!
Then it will anti-alias nicely against any background, and also any
overall transparency you might use will work as well.

I hope I managed to explain that in somewhat understandable terms…

Hmmm… unfortunatly not :wink:
Sorry but I’m starting on this subject. Can you explain further,
specialy this part:

The solution is actually to not have any anti-alias at the edges, but
only use edge-transparency => alpha channel!
How do I do that? I understand the images must not have an anti-alias
but I completly missed the 2nd part.

What you can do is divide the anti-aliased edge by the alpha channel:

the anti-aliased PIXEL_VALUE = COLOR * (alpha/255) +
BLACK * ((255-alpha)/255)

since BLACK is 0:

PIXEL_VALUE = COLOR * (alpha/255)

so:

COLOR = PIXEL_VALUE * (255/alpha)

so… for each pixel, where the alpha isn’t 0 and the PIXEL_VALUE is
less than alpha, compute the color as above…

That should fix your problem…

-LorenOn Mon, 2002-12-23 at 02:51, Adilson Oliveira wrote: