Re: Wierd problem when alpha blitting image with text in it
- From: "Nobody" <nobody@xxxxxxx>
- Date: Sat, 29 Jul 2006 23:50:49 -0700
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.
Thats correct... and pretty damn stupid as it prevents you from having an
alpha-blended main window or alpha-blended popups that have child controls.
But since you are not using windows controls, I'm not sure why you need to
simulate a popup. If the entire window can be pre-rendered into a memory DC,
you can use real popups and alpha-blend them just fine.
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.
No, what I said that unless you purposely initialize it otherwise, a bitmap
starts out with alpha = 0x00 for all pixels and none of the non-alpha aware
APIs will touch the alpha. That is, if you create a 32bit bitmap, its
initialized to ARGB = 0,0,0,0 for all pixels. So if you draw text on that
bitmap without changing any alpha values, you wont
see anything because it'll still be alpha = 0x00.
But now that I think about it, if you load your bitmap with alpha values, it
will "fix" the alpha values for the whole bitmap and you'll have alpha =
0xff for those areas... so thats not the problem.
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.
You know, I remember seeing this DrawText problem once now that you mention
it... I don't remember how/if I fixed it. But some ideas you may want to
try:
Are you using DrawText()? Maybe try mess around with SetBkMode(),
SetTextColor(), SetBkColor() to see if that has any effects. Also maybe try
ExtTextOut.
One wacky idea: try drawing the text on a 24bit DIB and TransparentBlt'ing
it over. Just as a test to see if that the problem.
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.
No, as I said, the standard non alpha aware APIs like DrawText do not affect
the alphas.
.
- 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
- Re: Wierd problem when alpha blitting image with text in it
- From: Dean Roddey
- 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: Office 2007 graphics engine
- 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
|