> 
> > I looked at those articles but did not really address my 
question.
> 
> Uhm, why? Maybe there's a misunderstanding and we are talking 
about 
> different things. If so, sorry for that. 

No need to be sorry as I am not really even sure if my question 
makes sense.  Let me try another approach.

This equation from the MS site describes alpha blending:

displayColor = sourceColor × alpha / 255 + backgroundColor × (255 – 
alpha) / 255

It says that the output color is a weighted average of the source 
picture pixel color you are painting and the background picture 
color it is being painted on.  This calculation is done separately 
for each of the three color components (RGB) in the pixel.

Alpha is a number between 0 and 255.  A 32 bit field can contain the 
24 bit RGB color plus an 8 bit weight alpha for that pixel.  So 
there can be a different alpha, in theory, for each pixel of 
source.  (AFAIK, no attempt is made to look at the 
corresponding "alpha" bits in the background image).


Now when you do translucent windows, the source picture is whatever 
is in your window and the background is whatever is under your 
window on the screen.  Only Windows systems routines like 
UpdateLayeredWindow can get at the other windows information 
reliably and make sure that your window gets repainted if they 
change.  So you need to use a Windows system routine to do 
translucent windows properly.

So my question is about UpdateLayeredWindows.  Where does it get the 
alpha that is uses to blend your window with the windows 
underneath?  Does it use the alpha in each pixel in what you draw in 
your window?  Or does it use the single alpha value that your pass 
to it for all pixels?  Or some combination.

I read the sample code in what you referenced.  Here is what I think 
it is doing:
1.  Reads image you provide it.
2.  Goes through each pixel in that image, and pre-multiplies the 3 
colors in the pixel by the alpha value in the pixel.  Note that 
since there is no background color involved, I don't think this is 
true alpha blending.
3.  Uses UpdateLayeredWindow to draw the bitmap resulting form 1 on 
the screen.  The alpha value used to call UpdateLayeredWindow is the 
one derived from the slider control that the application displays.  

As best I can understand the code, I still have the question about 
how UpdateLayeredWindows is working.  In fact, based on step 2, I 
would guess that the author believes the UpdateLayeredWindow ignores 
the alpha values in the bitmap.  Otherwise why pre-multiply 
(although, to repeat myself, this is not true blending, if I 
understand the code correctly).

Anyway, on your other question, I did say at one point that PNG 
support was too hard.  But I took a bit more time to understand GDI+ 
and realized that it would do most of the work for me for reading 
png files and doing the pixel-by-pixel alpha blending of an image 
and a background color.  Its when that image is asked to be 
transucently applied to the screen that I wonder what will happen.











Attention: PowerPro's Web site has moved: http://www.ppro.org 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/power-pro/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to