// Grows the cropping rectange by (dx, Dy) in image space. <br/> void growby (float dx, float Dy) {<br/> If (mmaintainaspectratio) {<br/> If (dx! = 0) {<br/> DY = dx/minitialaspectratio; <br/>} else if (dy! = 0) {<br/> dx = Dy * minitialaspectratio; <br/>}< br/> // don't let the cropping rectangle grow too fast. <br/> // grow at most half of the difference between the image rectangle and <br/> // The cropping rectangle. <br/> rectf r = new rectf (mcroprect); <br/> If (dx> 0f & R. width () + 2 * DX> mimagerect. width () {<br/> float adjustment = (mimagerect. width ()-R. width ()/2f; <br/> DX = Adjustment; <br/> If (mmaintainaspectratio) {<br/> DY = dx/minitialaspectratio; <br/>}< br/> If (dy> 0f & R. height () + 2 * dy> mimagerect. height () {<br/> float adjustment = (mimagerect. height ()-R. height ()/2f; <br/> DY = adjustment; <br/> If (mmaintainaspectratio) {<br/> dx = Dy * minitialaspectratio; <br/>}< br/> r. inset (-dx,-dy); <br/> // don't let the cropping Rectangle shrink too fast. <br/> final float widthcap = 25f; <br/> If (R. width () <widthcap) {<br/> r. inset (-(widthcap-R. width ()/2f, 0f); <br/>}< br/> float heightcap = mmaintainaspectratio <br/>? (Widthcap/minitialaspectratio) <br/>: widthcap; <br/> If (R. height () <peightcap) {<br/> r. inset (0f,-(heightcap-R. height ()/2f); <br/>}< br/> // put the cropping rectangle inside the image rectangle. <br/> If (R. left <mimagerect. left) {<br/> r. offset (mimagerect. left-R. left, 0f); <br/>} else if (R. right> mimagerect. right) {<br/> r. offset (-(R. right-mimagerect. right), 0); <br/>}< br/> If (R. top <mimagerect. top) {<br/> r. offset (0f, mimagerect. top-R. top); <br/>} else if (R. bottom> mimagerect. bottom) {<br/> r. offset (0f,-(R. bottom-mimagerect. bottom); <br/>}< br/> mcroprect. set (r); <br/> mdrawrect = computelayout (); <br/> mcontext. invalidate (); <br/>}
Mcroprect. offset (dx, Dy); // At the beginning, the offset is so much. There are so many Dx and Dy.
// Put the cropping rectangle inside image rectangle.
Mcroprect. offset (
Math. Max (0, mimagerect. Left-mcroprect. Left ),
Math. Max (0, mimagerect. Top-mcroprect. Top ));
//
Because mimagerect. Top-mcroprect. Top <= 0 indicates moving internally.
Mimagerect. Top-mcroprect. Top> = 0. It indicates that mcroprect has been removed from the corresponding mimagerect. Top-mcroprect. Top, which is based on the original one. Mcroprect. Top + (mimagerect. Top-mcroprect. Top) --> ensure that it is internal.
Mcroprect. offset (
Math. Min (0, mimagerect. Right-mcroprect. Right ),
Math. Min (0, mimagerect. Bottom-mcroprect. Bottom ));
Offset to control the movement of the mcroprect area.
// Grows the cropping rectange by (dx, Dy) in image space. <br/> void moveBy (float dx, float Dy) {<br/> rect invalrect = new rect (mdrawrect); <br/> mcroprect. offset (dx, Dy); <br/> // put the cropping rectangle inside image rectangle. <br/> mcroprect. offset (<br/> math. max (0, mimagerect. left-mcroprect. left), <br/> math. max (0, mimagerect. top-mcroprect. top); <br/> mcroprect. offset (<br/> math. min (0, mimagerect. right-mcroprect. right), <br/> math. min (0, mimagerect. bottom-mcroprect. bottom); <br/> mdrawrect = computelayout (); <br/> invalrect. union (mdrawrect); <br/> invalrect. inset (-10,-10); <br/> mcontext. invalidate (invalrect); <br/>}