O'Reilly logo

Graphics Programming with GDI+ by Mahesh Chand

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7.8. Drawing Transparent Graphics Objects

Sometimes we need to draw objects on top of images—and these objects may need to be transparent. As we discussed earlier, color in GDI+ has four components: alpha, red, green, and blue. The value of each component varies from 0 to 255. The alpha component represents the transparency in GDI+ color. Zero represents a fully transparent color; 255, a fully opaque color.

An application must create transparent pens and brushes to draw transparent graphics objects. An application can use the Color.FromArgb method to specify the ratio of all four components in a color. For example, the following code snippet creates a fully opaque green pen and brush.

 Pen solidPen = new Pen(Color.FromArgb(255, 0, 255, 0), 10); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required