views:

62

answers:

3

I need a control that allows loading a picture, performing some basic drawing tasks with it (including adding text, pencil, oval, horizontal and diagonal lines), and exporting it as bitmap. Anything like that available?

Thanks

+1  A: 

Image is a good container for this task:

// Load the image from an existing file
using (var img = Image.FromFile("test.png"))
using (var g = Graphics.FromImage(img))
{
    // Scratch on it
    g.DrawLine(new Pen(Color.Red, 10), new Point(0, 0), new Point(100, 100));
    g.DrawEllipse(new Pen(Brushes.Black), 10, 10, 100, 100);
    g.DrawRectangle(new Pen(Brushes.Red), 30, 30, 40, 40);

    // Save to a new file
    img.Save("test2.png");
}
Darin Dimitrov
I expect that the OP wants a control which accepts user input, e.g. with a toolbar.
ChrisW
@ChrisW: probably, but it's not hard to cook a custom control up.
codekaizen
ChrisW: that's right, I need a control with toolbar. It's definitely possible to write it from scratch, but I thought maybe a solution exists already.
Sphynx
+1  A: 

Check this nice article about image processing: http://www.codeproject.com/KB/GDI-plus/Image_Processing_Lab.aspx

And this: http://www.codeproject.com/KB/graphics/Painter.aspx

Pierre 303
A: 

I've made my own control based on Mouse_Down, Mouse_Up, and Mouse_Move events of PictureBox.

Sphynx