tags:

views:

18

answers:

1

How can I set the alpha channel of a pixel to zero using .Net GDI+ or API calls? How can I set to transparent a shaped area (for instance, having sort of an"Erasing" brush and using it with FillEllipse() or FillRectangle() methods) ?

Thank you.

+1  A: 

You can use a brush that's made from a Color that has an alpha of 0 (Color.FromArgb). Since the RGB values don't really matter anymore, you might as well use Brushes.Transparent. Make a single pixel transparent by drawing a rectangle of 1x1 with Graphics.FillRectangle().

Bitmap.MakeTransparent() is another way to quickly make an arbitrary background color transparent.

Hans Passant