Draw on ImageBox and save the image

Started by Deer2014, April 19, 2021, 09:10:12 PM

Previous topic - Next topic

Deer2014

Hello Richard,

Can I draw basic shapes on ImageBox like a Rectangle, Circle, Line, etc?
How can I save this image to have the drawn shape on it?

Can you help me with an example, please.
Thanks.

Regards,
Deeron

Richard Moss

Check the Virtual Mode demonstration for an example of doing custom painting. If you don't wish to use this mode then hook into the Paint event and do your custom drawing there.

To draw on top of an existing image you'd need to create a Graphics object to draw onto. See the MSDN documentation for Graphics.FromImage for an example.

Deer2014

#2
Thanks Richard.

If I draw on the loaded image can I save it?  Because I drew a rectangle through the Paint event but it only saved the blank image. I do something wrong.