简体   繁体   中英

How to make a resizeable rectangle selection tool?

I'm trying to write a very simple photo editor using C# 2008 or QT4.

How to make a resizeable rectangle selection tool like the photoshop did?

如果您正在谈论“经典”“橡皮筋”类型的选择矩形,请查看如何在Visual C#中绘制橡皮筋矩形或焦点矩形

WPF Code Example: http://www.codeproject.com/KB/WPF/wpfmarchingants.aspx?display=Print

This one is a bit more complicated because it involves image cropping, but if you scroll down to the selection rectangle, you can see the basic formulas for calculating the rectangle: http://69.10.233.10/KB/WPF/ImageCropper.aspx

Lastly, another one using GDI: http://codelog.blogial.com/2008/10/31/rubber-band-selection-rectangle-in-c/

If you provide more specifics, I'm sure we can help you out more.

I don't know the specific calls, but the idea is this:

You want to draw a transparent rectangle with an opaque or dotted border. The rectangle appears when the mouse button is clicked. While the button is held, the dimension of the rectangle will change as the mouse moves, with the top-left point at the position where the button was clicked and the bottom-right following the mouse as it moves. Releasing the button causes the rectangle to fix its position over the selection area.

You should be able to figure out the particulars from a resource on the C# Drawing namespace.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM