James T
James T

Reputation: 3320

.net "Canvas" control

I'm trying to (for educational purposes) create a image format, in order to display I'd like to be able to do something like SetPixel on some control to draw a pixel in the display area. How can I do this?

Upvotes: 0

Views: 1134

Answers (2)

Anton Semenov
Anton Semenov

Reputation: 6347

The most appropriate class for you is Bitmap which you can draw stright on form via Graphics class. Here is example:

    private void Form1_Paint(object sender, PaintEventArgs e)
    {
        Bitmap bmp = new Bitmap(640, 480);
        bmp.SetPixel(10, 12, Color.Green);

        e.Graphics.DrawImage(bmp, new Point(0, 0));
    }

Upvotes: 3

NerdFury
NerdFury

Reputation: 19214

Not sure if this is in line with what you are trying to do. But you could use the GDI+ libraries (System.Drawing) to get started. You will want to use the Bitmap class, and use the SetPixel() methods to "draw" on the image. Then you can use the PictureBox control and just keep updating it to the bitmap you are manipulating.

Upvotes: 0

Related Questions