question: private void applyImageMatrix ( float width , float height , boolean center , boolean animate ) { if ( mBitmap != null && width > 0 && height > 0 ) { mImageMatrix . reset ( ) ; mImageMatrix . postTranslate ( ( width - mBitmap . getWidth ( ) ) / 2 , ( height - mBitmap . getHeight ( ) ) / 2 ) ; mapImagePointsByImageMatrix ( ) ; if ( mDegreesRotated > 0 ) { mImageMatrix . postRotate ( mDegreesRotated , BitmapUtils . getRectCenterX ( mImagePoints ) , BitmapUtils . getRectCenterY ( mImagePoints ) ) ; mapImagePointsByImageMatrix ( ) ; } float scale = Math . min ( width / BitmapUtils . getRectWidth ( mImagePoints ) , height / BitmapUtils . getRectHeight ( mImagePoints ) ) ; if ( mScaleType == ScaleType . FIT_CENTER || ( mScaleType == ScaleType . CENTER_INSIDE && scale < 1 ) || ( scale > 1 && mAutoZoomEnabled ) ) { mImageMatrix . postScale ( scale , scale , BitmapUtils . getRectCenterX ( mImagePoints ) , BitmapUtils . getRectCenterY ( mImagePoints ) ) ; mapImagePointsByImageMatrix ( ) ; } mImageMatrix . postScale ( mZoom , mZoom , BitmapUtils . getRectCenterX ( mImagePoints ) , BitmapUtils . getRectCenterY ( mImagePoints ) ) ; mapImagePointsByImageMatrix ( ) ; RectF cropRect = mCropOverlayView . getCropWindowRect ( ) ; cropRect . offset ( - mZoomOffsetX * mZoom , - mZoomOffsetY * mZoom ) ; if ( center ) { mZoomOffsetX = width > BitmapUtils . getRectWidth ( mImagePoints ) ? 0 : Math . max ( Math . min ( width / 2 - cropRect . centerX ( ) , - BitmapUtils . getRectLeft ( mImagePoints ) ) , getWidth ( ) - BitmapUtils . getRectRight ( mImagePoints ) ) / mZoom ; mZoomOffsetY = height > BitmapUtils . getRectHeight ( mImagePoints ) ? 0 : Math . max ( Math . min ( height / 2 - cropRect . centerY ( ) , - BitmapUtils . getRectTop ( mImagePoints ) ) , getHeight ( ) - BitmapUtils . getRectBottom ( mImagePoints ) ) / mZoom ; } else { mZoomOffsetX = Math . min ( Math . max ( mZoomOffsetX * mZoom , - cropRect . left ) , - cropRect . right + width ) / mZoom ; mZoomOffsetY = Math . min ( Math . max ( mZoomOffsetY * mZoom , - cropRect . top ) , - cropRect . bottom + height ) / mZoom ; } mImageMatrix . postTranslate ( mZoomOffsetX * mZoom , mZoomOffsetY * mZoom ) ; cropRect . offset ( mZoomOffsetX * mZoom , mZoomOffsetY * mZoom ) ; mCropOverlayView . setCropWindowRect ( cropRect ) ; mapImagePointsByImageMatrix ( ) ; if ( animate ) { mAnimation . setEndState ( mImagePoints , mImageMatrix ) ; mImageView . startAnimation ( mAnimation ) ; } else { mImageView . setImageMatrix ( mImageMatrix ) ; } updateImageBounds ( false ) ; } }
target:  Apply matrix to handle the image inside the image view.