Search This Blog

Tuesday, December 10, 2013

C# Create new bitmap example

C# > Drawing > Bitmap

Bitmap contains  pixel data for a graphics image. You can save bitmap to GDI+ file formats: BMP, GIF, EXIF, JPG, PNG and TIFF.

Example
Create new bitmap in runtime


Bitmap bmp = new System.Drawing.Bitmap(200, 200);
for (int x = 0; x < bmp.Height; ++x)
   for (int y = 0; y < bmp.Width; ++y)
     bmp.SetPixel(x, y, Color.Coral );
for (int x = 0; x < bmp.Height / 2; ++x)
   for (int y = 0; y < bmp.Width / 2; ++y)
     bmp.SetPixel(x, y, Color.Blue );
pictureBox1.Image = bmp;