René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback
 

Set Pixel in Bitmap with .NET

using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;

public class GdiTest : Form {

   GdiTest() {
     Width=512;
     Height=512;
     bmp = new Bitmap(256,256,PixelFormat.Format32bppArgb);

     for (int i=0;i<256; i++) {
       bmp.SetPixel(i,i,Color.FromArgb(255,255-i,i,0));
     }
   }

   protected override void OnPaint(PaintEventArgs e) {
      Graphics g = e.Graphics;

      g.DrawImage(bmp,128,128);
   }

   public static void Main() {
      Application.Run(new GdiTest());
   }

   private Bitmap bmp;
}