I have made a small example of per-pixel alpha blending on a window. It uses Thomas' PngLib to load a png file with a alpha channel, and uses this image to create a transparent window. Below is a screenshot of what this looks like.

Note that this program uses UpdateLayeredWindow, so you need WinXP or 2000 to run it.

Download it from my website: http://www20.brinkster.com/qweerdy/ (Sorry, brinkster doesn't support direct linking.)
Posted on 2002-08-27 06:43:32 by Qweerdy
I wonder how fast Windows' alpha blending is compared bitRAKEs optimized MMX-code included in the Amethyst lib. Is there a way to do a comparision? Maybe windows is using hardware alpha-blending when possible.
Posted on 2002-08-27 07:11:29 by Delight
I'm not sure if the WinXP AlphaBlend API uses the same method of alphablending since you have to preprocess the image before alphablending ("Pre-multiplying", see my code).
Posted on 2002-08-27 08:42:53 by Qweerdy
Hi Qweerdy

I tried to convert your code in order to allow it to work on win98/win95 users.

Can you or anyone else who has win98/win95 see if this worked ?

All i did was insert the main UpdateLayeredWindow function on the main asm file.

Normally if the function don't make complex calls it works, but now i don't have how to test it on my machine.

Other thing, i tried to bypass the push ebp, mov .... that the invoke procs uses as default.

But i can't make them, so i made them look as:


mov eax, 122Dh
lea edx,
int 2Eh
ret 24h

I wanted to make they work as a regular invoke instead a call procedure, but the main code should remains as it is without the push ebp stuff.

Here is the file:


Posted on 2002-08-27 12:18:02 by Beyond2000!
Nice example Qweerdy!

I don't know if this is any better?
Untested, but it looks like it should work:

mov ecx,bminfo.bmWidth
mov eax,[esi]
mov edx,eax
rol eax,16
shr edx,24 ; A
mul dl ; B * A
rol eax,8
mul dl ; G * A
rol eax,8
mul dl ; R * A
mov al,dl
ror eax,8
mov [esi],eax
add esi,4
dec ecx
jnz xloop
dec bminfo.bmHeight
jnz yloop
Posted on 2002-08-27 19:34:05 by bitRAKE
bitRAKE - works perfectly! Now I can't even take credit for the pre-multiply proc :grin:

Beyond2000! - I don't really see how that could work unless Win98 already has a UpdateLayeredWindow deep inside it. What I think that proc does is just pass control to a kernel-level API through a interupt. To make it work you'd also need that API's code.
Posted on 2002-08-28 00:33:45 by Qweerdy
As we are speaking about transparency, here is my example of it. It uses API hooking to modify notepads window to look transparent.

I think this only works on Windows 2000 and XP, because of use of the RemoteThreads and LayeredWindows :(
Posted on 2002-08-29 14:21:14 by SamiP
Nice SamiP. Works like a charm on XP.
Posted on 2002-08-30 03:39:37 by huh
I modified the original demo to scroll a PNG file, kind of like movie credits, but with the text fading in and out at the top and bottom. Check it out at my site, if you liked the first one... this is much better.

http://www20.brinkster.com/qweerdy (Programs section, bottom)
Posted on 2002-08-30 09:57:11 by Qweerdy
Hi Qweerdy

your site seems to be down, can you pls post your app here ?


Best Regards,

Posted on 2002-08-30 19:49:07 by Beyond2000!
Probably that's just brinkster going down again for the usual 20 minutes. They're always crashing :(

Anyway, here it is...
Posted on 2002-08-31 02:09:49 by Qweerdy