Reputation: 842
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?
Upvotes: 3
Views: 3651
Reputation: 36026
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.
Upvotes: 3
Reputation: 308158
Any chance of using GDI+ instead of GDI? It supports antialiasing and transparency right out of the box.
Upvotes: 0
Reputation: 75296
You can do this in C# using the LockBits method of the BitMap class (see this question for an explanation). You definitely don't want to use GetPixel and SetPixel for this, as they are hideously slow (even though you'd just be manipulating the edges and not the entire bitmap).
Upvotes: 0