Re: Transparent Merging (Antialias problems)
From: Rob Kennedy (me3_at_privacy.net)
Date: 12/02/04
- Next message: Lodewijk Bogaards: "Re: Idea"
- Previous message: Uwe Labs: "Re: Delphi 2005, TextFile misbehavier?"
- In reply to: Osmosis: "Re: Transparent Merging (Antialias problems)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 02 Dec 2004 10:09:01 -0600
Osmosis wrote:
> Are there any kind of algorythms to get the alpha values of the foreground
> picture ?
Probably. For each pixel, look at the alpha value and store it in some
other data structure. That data structure might be in the form of a
grayscale bitmap.
> I 'm currently thinking that it wouldn't really matter whether the
> background color is green or white or black or any other color as long as
> you set the transparentcolor to that color.
When dealing with alpha values, there isn't really such a thing as "the"
transparent color. Transparency is determined entirely by the alpha values.
> But I'm having trouble with
> determining the alpha values, because in each case these alpha values should
> be the same, isn't it ?
Not if your text is antialiased.
When you draw antialiased text, the pixels around the edges will not
have the same 32-bit color values as the pixels on the interior. With
standard antialiasing, the 24-bit text color is blended with the 24-bit
background color; the alpha value is assumed to be a constant 100%
opaque. If you then try to remove pixels based on the background color,
you'll get a fuzzy edge around the text because those pixels aren't the
same as the background color. They're a combination of the background
color and the text color.
What you need to do instead is to start with a fully transparent (alpha
= 0) foreground image, and when you draw your text, do the antialiasing
in terms of the alpha value; the 24-bit color value will be the same
throughout the text, and only the alpha values will vary.
Now, when you blend the foreground bitmap with the background bitmap,
blend the full 32-bit color values. The parts of the foreground that are
fully transparent will not get blended at all because of their 0 alpha
values. The parts of the foreground image with intermediate alpha values
will blend with the background image proportionally to their alpha
values, so the new pixels will be partially the text color and partially
the background pixels' colors.
I suggest you try using Graphics32, a Delphi graphics library. It
supports antialiased text and alpha transparency natively.
http://www.g32.org/
-- Rob
- Next message: Lodewijk Bogaards: "Re: Idea"
- Previous message: Uwe Labs: "Re: Delphi 2005, TextFile misbehavier?"
- In reply to: Osmosis: "Re: Transparent Merging (Antialias problems)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|