Sets the RGB color of a particular pixel. This function is provided for compatibility with System.Drawing. However for efficiency and flexibility you should prefer BitmapData.SetPixel.
Syntax

[C#]

void SetPixel(int x, int y, Color color);

[Visual Basic]

Sub SetPixel(x As Integer, y As Integer, color As Color)
Params
Name Description
x The x coordinate.
y The y coordinate.
color The Color.
Notes

None.

Example

[C#]using (Bitmap small = new Bitmap(2, 2)) {
  small.SetPixel(0, 0, Color.Red);
  small.SetPixel(1, 0, Color.Green);
  small.SetPixel(0, 1, Color.Blue);
  small.SetPixel(1, 1, Color.Black);
  using (Bitmap big = new Bitmap(small, small.Size * 250)) {
    big.Save(Server.MapPath("IG8_Bitmap_SetPixel.jpg"));
  }
}


Here we make a create a small Bitmap and set the colors in the pixels. To make it easier to see we scale the Bitmap up before saving. The output file is shown below.


IG8_Bitmap_SetPixel.jpg