movable rectangle on image
-
Is there a way to draw a rectangle on top of a loaded image that a user can drag to create a selection area? I can make a rectangle and have it follow the mouse movements, but i don't know how to redraw the underlying image to clear the dragging effect. The image in the picturebox is rather large (10000x10000 pix give or take). Any help or pointers is much appreciated. R.Myers
-
Is there a way to draw a rectangle on top of a loaded image that a user can drag to create a selection area? I can make a rectangle and have it follow the mouse movements, but i don't know how to redraw the underlying image to clear the dragging effect. The image in the picturebox is rather large (10000x10000 pix give or take). Any help or pointers is much appreciated. R.Myers
R.Myers wrote:
can make a rectangle and have it follow the mouse movements, but i don't know how to redraw the underlying image to clear the dragging effect.
Do you use double buffering? First draw both the image and the rectangle to an offscreen surface and then present it on the screen. regards
-
Is there a way to draw a rectangle on top of a loaded image that a user can drag to create a selection area? I can make a rectangle and have it follow the mouse movements, but i don't know how to redraw the underlying image to clear the dragging effect. The image in the picturebox is rather large (10000x10000 pix give or take). Any help or pointers is much appreciated. R.Myers
If you're drawing onto the actual Image in the picturebox (IE through Graphics.FromImage() ) then the actual image is going to be edited and you won't be able to "clear" it without loading the image again (expensive for a huge image like that!). Instead what you should do is override the OnPaint event of the PictureBox and take its graphic region from the PaintEventArgs (PaintEventArgs.Graphics), and then do your drawing there.
-
If you're drawing onto the actual Image in the picturebox (IE through Graphics.FromImage() ) then the actual image is going to be edited and you won't be able to "clear" it without loading the image again (expensive for a huge image like that!). Instead what you should do is override the OnPaint event of the PictureBox and take its graphic region from the PaintEventArgs (PaintEventArgs.Graphics), and then do your drawing there.