Archived

This topic is now archived and is closed to further replies.

Utwo

Alpha blending with GDI?

Recommended Posts

I''m making a game with GDI and I can''t seem to find out how or if alpha blending is possible. Is there an API function that can blit semi-transparent bitmaps? Perhaps through the use of a seperate alpha bitmap and a SRC-value type of a thing? Also, one of the things I plan to use alpha for is to make my screen fade in and out of black between menu transitions. Is there a better way to accomplish this effect?

Share this post


Link to post
Share on other sites
If you limit your audience to Windows 98/ME/XP/2000 users, GDI has an AlphaBlend function that will do what you want. If you absolutely have to run under Windows 95 and NT you''ll need to write your own alpha blended blit routine.

Share this post


Link to post
Share on other sites
Thanks.

Holy crap. That by far looks like the most complicated API function I''ve run into yet. Why can''t I just blit a grayscale image first, and then the color image on top of it? Sure there are some bit depth issues but you''d think that they would have written AlphaBlend to take care of that, for the sake of making it easier on people like me.

Oh well. What does not kill me makes me stronger. Looking ahead to DirectX, it looks like I''ll need a lot more strength.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
gdi screen fades may be accomplished via the gamma ramp functions GetDeviceGammaRamp and SetDeviceGammaRamp or, on some Windows versions (2K, XP, possibly ME and 98), via applying varying degrees of transparency to a layered desktop window (WS_EX_LAYERED) using SetLayeredWindowAttributes.

also, DIBs are used quite often as a Windows-version independent solution to provding alpha blending capabilities. there are a few DIB C++ classes floating around on the web that provide basic PS/PS-like effects functions (dodge, burn, blend, etc.) some of them make use of the AlphaBlend and TransparentBlt functions if they''re available.

Share this post


Link to post
Share on other sites