Re: Wierd problem when alpha blitting image with text in it
- From: "Dean Roddey" <droddey@xxxxxxxxxxxxxxxx>
- Date: Sat, 29 Jul 2006 23:02:35 -0700
Layered windows support per-pixel and source constant alphas
simultaneously. In fact, I use that very thing in my project to fade
out alpha-blended drop shadows. The shadow itself is built of 4 rows of
per-pixel alpha blended bitmap. When the shadow is faded out, the source
constant alpha is applied to the whole window.
Sorry, I was speaking loosely. As I understand it, manually updated layered
windows can have per-pixel but cannot have any child windows. The
'compatible' style layered windows can have child windows but can only do
constant opacity, not per-pixel. So it's a bit of a compromise either way.
Anyway, in the end and as explained in the first post, I don't need to use
separate windows anyway since all our widgets are graphical and recursively
drawn via a nested set of objects, so it was easy to plop another set on top
of the base image and simulate a popup.
I'm not sure how that window is being painted code wise, but I would have
the background (the white area and the translucent rounded frame and
purple area) loaded as a 32bit DIB preserving the alphas. The inside white
area would then have 0xff alphas by design. Then paint on top of that. But
you need to use that "HBITMAP" as your base and not something thats the
result of CreateCompatibleBitmap().
Basically that's it. As explained in the initial post, the base interface is
drawn it it's own bitmap. It's always opaque since it's the main interface
background. The 'popup' is drawn into a secondary bitmap, which is initially
set with all pixels transparent. The background image chosen by the user is
either alpht blitted or color transparency blitted in, according to the type
of image. So this leaves me with the image pixels being however opaque they
were in the original image. It's not a problem to require that if they want
to layer any text over over it that it be on fully opaque parts of the
image.
So anyway, I've not got a second bitmap that has the image background. If I
stop there and just alpha blit that onto the background layer, all is well.
I can apply constant alpha to it and it composites on as you'd expect.
But, if I draw text on that second layer, and if that sets the alpha channel
on those pixels to be fully transparent (as you said previously), then it
will never work because now the wherever the text was going to be, it will
be transparent. I don't see that happening, so I don't think that it really
works that way. The problem is more than that text pixels end up over-amped
when composited over the base image. If I draw it straight onto the base
image (which prevents applying constant alpha), it looks fine. If I just do
a straight blit, the text looks fine but of course the background black area
that's supposed to be transparent shows up.
It's only if I alpha blit from the first to the second that the text pixels
get whacked, but everything else stays fine. At first I thought maybe it's
because the pixels are pre-blended but the drawn text pixels aren't (they
get an 0xFF I assume.) But the area of the image over which the text is
being drawn is fully opaque and would have 0xFF alpha anyway, so that
doesn't seem likely.
Both bitmaps are fully 32 bit.
P.S. Nice UI, except the drop shadow is on the wrong side :). The "sun"
comes from the upper left, so the shadow should be on the lower right, not
the lower left.
The images up the upper right that I drew have the shadow going left, so I
did the popup the same way so that it looked consistent. I originally had it
the other way but changed it. Oh, and BTW, all of this stuff is just created
using our interface designer, so it's not hard coded stuff, it's designed
screens for use with our automation system.
-------------------------------------
Dean Roddey
Chairman/CTO, Charmed Quark Systems
www.charmedquark.com
.
- Follow-Ups:
- Re: Wierd problem when alpha blitting image with text in it
- From: Chris Hill
- Re: Wierd problem when alpha blitting image with text in it
- From: Nobody
- Re: Wierd problem when alpha blitting image with text in it
- References:
- Wierd problem when alpha blitting image with text in it
- From: Dean Roddey
- Re: Wierd problem when alpha blitting image with text in it
- From: Dean Roddey
- Re: Wierd problem when alpha blitting image with text in it
- From: Nobody
- Re: Wierd problem when alpha blitting image with text in it
- From: Dean Roddey
- Re: Wierd problem when alpha blitting image with text in it
- From: Nobody
- Wierd problem when alpha blitting image with text in it
- Prev by Date: Re: Wierd problem when alpha blitting image with text in it
- Next by Date: Re: Wierd problem when alpha blitting image with text in it
- Previous by thread: Re: Wierd problem when alpha blitting image with text in it
- Next by thread: Re: Wierd problem when alpha blitting image with text in it
- Index(es):
Relevant Pages
|