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;
}

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 ; }
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 ) .
