Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a bitmap with an alpha channel on the fly using GDI?

I am using layered windows and drawing a rounded rectangle on the screen. However, I'd like to smooth out the jagged edges. I think that I'll need alpha blending for this. Is there a way I can do this with GDI?

like image 434
wkf Avatar asked Nov 21 '25 01:11

wkf


1 Answers

CreateDIBSection. Fill in the BITMAPINFOHEADER with 32bpp. Fill in the alpha channel with pre-multiplied alpha and youre good to go.

AlphaBlend is the API to actually blit 32 bpp bitmaps with an aplha channel.

like image 155
Chris Becke Avatar answered Nov 24 '25 03:11

Chris Becke