Create image in C#

Viewed 12640

I have to apply a Fourier Transform on an image. For this, I want to create a new image with the transform. It is possible to create an image pixel by pixel? Or do I have to modify my basic image?

1 Answers

Yes, you can do it.

public void Draw()
{
    var bitmap = new Bitmap(640, 480);

    for (var x = 0; x < bitmap.Width; x++)
    {
        for (var y = 0; y < bitmap.Height; y++)
        {
            bitmap.SetPixel(x, y, Color.BlueViolet);
        }
   }

   bitmap.Save("m.bmp");
}

But it may be slowly, if you want draw big bitmaps.

You can draw in the same way on an existing image. You can get it like this:

var bitmap = new Bitmap("source.bmp");

Use this constructor to open images with the following file formats: BMP, GIF, EXIF, JPG, PNG and TIFF.

Related