How can I change the background color of an image using GDI+?

user496949 picture user496949 · Dec 29, 2010 · Viewed 18.9k times · Source

I want to know how to change the background color when I generate the image dynamically.

Answer

Flipster picture Flipster · Dec 29, 2010

Just use the Graphics object .Clear() method, passing the color you wish to use for the background.

For example:

g.Clear(Color.Blue);