How to make a resizeable rectangle selection tool?

前端 未结 4 527
夕颜
夕颜 2021-01-02 20:12

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?

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-02 20:54

    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.

提交回复
热议问题