Clears the drawing area and sets it to a particular color. If the color provided is transparent then no color will be assigned to the background. The Backdrop property provides a more efficient way of achieving a similar goal.
Syntax

[C#]

void Clear(Color color);

[Visual Basic]

Sub Clear(color As Color)
Params
Name Description
color The background color to use.
Notes

None.

Example

[C#]using (Image bm = Bitmap.FromFile(Server.MapPath("rez/farshad-rezvanian-Eelegt4hFNc-unsplash.jpg"))) {
  using (Graphics img = Graphics.FromImage(bm)) {
    bm.Save(Server.MapPath("IG8_Graphics_Clear_Before.gif"));
    img.Clear(Color.BurlyWood);
    bm.Save(Server.MapPath("IG8_Graphics_Clear_After.gif"));
  }
}


Sample files are shown below.


farshad-rezvanian-Eelegt4hFNc-unsplash.jpg


IG8_Graphics_Clear_Before.gif


IG8_Graphics_Clear_After.gif