Alexandre S.
Alexandre S.

Reputation: 540

Create image in C#

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?

Upvotes: 8

Views: 21197

Answers (1)

Anton Gorbunov
Anton Gorbunov

Reputation: 1444

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.

Upvotes: 13

Related Questions