Select a portion of image in ImageView and retrieve the end points of selected rectangle

后端 未结 3 1096
灰色年华
灰色年华 2020-12-05 06:16

I need to drag and select a portion of an image set in an ImageView and retrieve the end points of the selected rectangle without causing any modifications (suc

3条回答
  •  攒了一身酷
    2020-12-05 06:46

    I just tried out your solution, it's pretty cool. Maybe I am wrong, but I think there is a typo in your Toast output:

    mCallback.onRectFinished(new Rect(Math.min(mStartX, mEndX), Math.min(mStartY, mEndY),
                            Math.max(mEndX, mStartX), Math.max(mEndY, mStartX)));
    

    must be:

    mCallback.onRectFinished(new Rect(Math.min(mStartX, mEndX), Math.min(mStartY, mEndY),
                            Math.max(mEndX, mStartX), Math.max(mEndY, mStartY)));
    

    otherwise the value of the bottom sometimes is calculated wrong.

提交回复
热议问题