question: public Rect guaranteedSafeCrop ( int width , int height , @ Nullable Rect crop ) { if ( crop == null ) { return new Rect ( 0 , 0 , width , height ) ; } Rect safeCrop = new Rect ( crop ) ; if ( crop . top > crop . bottom || crop . left > crop . right || crop . width ( ) <= 0 || crop . height ( ) <= 0 ) { return new Rect ( 0 , 0 , 0 , 0 ) ; } safeCrop . left = Math . max ( safeCrop . left , 0 ) ; safeCrop . top = Math . max ( safeCrop . top , 0 ) ; safeCrop . right = Math . max ( Math . min ( safeCrop . right , width ) , safeCrop . left ) ; safeCrop . bottom = Math . max ( Math . min ( safeCrop . bottom , height ) , safeCrop . top ) ; if ( safeCrop . width ( ) <= 0 || safeCrop . height ( ) <= 0 ) { return new Rect ( 0 , 0 , 0 , 0 ) ; } return safeCrop ; }
target:  Returns a crop rectangle whose points are a strict subset of the points specified by image rectangle. A Null Intersection returns Rectangle(0,0,0,0). Since sometimes the ImageProxy doesn't take into account rotation.  The Image is assumed to have its top-left corner at (0,0).