Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 851
user496949 Avatar asked Dec 29 '10 03:12

user496949


People also ask

How can I change the background color of an image?

Changing a picture's background color is super easy and fast using Fotor's online background color changer. Simply click the "Change Background Color Now" button on this page. Click "Open Image" to upload the picture you want to change background color. Or directly drag the photo to the editing area.

How do I change the background color in OpenGL?

glClearColor(0,0,1,0); then recompile the program and run it. The background of the OpenGL window should be blue. Colors in OpenGL are typically represented in RGB or RGBA mode.

How do I change the background in Inkscape?

To change the default background color in Inkscape, open up the Document Properties menu by pressing Control + Shift + D, then click on “Background color” and set it to any color you'd like using the menu interface.


2 Answers

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

For example:

g.Clear(Color.Blue);
like image 160
Flipster Avatar answered Oct 06 '22 00:10

Flipster


It's simple:

Graphics graph = Graphics.FromImage(bitmap);
graph.Clear(Color.Yellow); // set color for background
like image 38
keminona Avatar answered Oct 06 '22 00:10

keminona