Re: UpdateLayeredWindow and alpha values

From: josh (smileyfaceswillruletheworld_at_yahoo.com.NOSPAM)
Date: 02/25/04


Date: Wed, 25 Feb 2004 15:07:50 -0800


"a.m.a" <amarcaurele@videotron.ca> wrote in
news:wZM_b.61704$FO1.1706154@weber.videotron.net:

> "josh" wrote :
>> out = background*(255-alpha)/255 + foreground*alpha/255
>
> then isnt that the same as :
>
> out = ( background*(255-alpha)/255) + (foreground*alpha/255)
> ...
> out = ( background * 1 ) + (foreground * 0)
> ...
> out = background + 0

Right, *IF* you are replacing foreground with your pixel values.
UpdateLayeredWindow uses your pixels to replace the entire term,
"foreground*alpha/255", not just the foreground value.

> Yet i assure you that the layered window does not display the
> pixels that this formula tels it should.

This is the complete alpha equation, UpdateLayeredWindow takes care of
the background half, the caller is respondible for the foreground half.
that's what premuliplication refers to.

That is, layered windows only do:
out = background*(255-alpha)/255 + bitmap

(at least, as far as per-pixel alpha is conserned)

>> (consider an alpha of 1, what should it do?)
> it should display a very faint pixel, wich is exactly what happens.

With a red component of 255?

> if ( RGB )
> if ( ! alpha )
> alpha = 255

If your source bitmap may or may not have an alpha channel, it would be
better to determine if the alpha channel is present for the entire image
rather than per pixel.

-josh

    



Relevant Pages

  • Re: dilation
    ... one pixel off, and I had array index out of bound errors). ... int foreground = 255; ... //create binary image from the input image ... //foreground, i set it to foreground value and exit for cycle. ...
    (sci.image.processing)
  • Re: dilation
    ... pixel to the current pixel for each foreground pixel in the kernel. ... static const unsigned char background = 255; ... int k = 1; ...
    (sci.image.processing)
  • Re: dilation
    ... It looks exact the same of the input image (tempimg) ... pixel to the current pixel for each foreground pixel in the kernel. ... int h,w; ...
    (sci.image.processing)
  • Re: Obtaining a portion of an image without loss of quality
    ... possible that the source image contains an alpha channel, ... > Hi Nick, ... > the image created by looping through each pixel. ... >> Hi Steve, ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: UpdateLayeredWindow appears illogical?
    ... pixel requirement but again, it doesn't make sense to me. ... the call to UpdateLayeredWindow (so, after I've done all my drawing to the ... memory DC and I'm ready to update the window), ... I wrote my own premultiply loop and I've used the ...
    (microsoft.public.win32.programmer.gdi)

Loading