@@ -58,9 +58,12 @@ public class CropImageView extends FrameLayout {
5858 /** Progress bar widget to show progress bar on async image loading and cropping. */
5959 private final ProgressBar mProgressBar ;
6060
61- /** Rectengale used in image matrix transformation calculation (reusing rect instance) */
61+ /** Rectangle used in image matrix transformation calculation (reusing rect instance) */
6262 private final float [] mImagePoints = new float [8 ];
6363
64+ /** Rectangle used in image matrix transformation for scale calculation (reusing rect instance) */
65+ private final float [] mScaleImagePoints = new float [8 ];
66+
6467 /** Animation class to smooth animate zoom-in/out */
6568 private CropImageAnimation mAnimation ;
6669
@@ -323,10 +326,10 @@ public CropImageView(Context context, AttributeSet attrs) {
323326 LayoutInflater inflater = LayoutInflater .from (context );
324327 View v = inflater .inflate (R .layout .crop_image_view , this , true );
325328
326- mImageView = ( ImageView ) v .findViewById (R .id .ImageView_image );
329+ mImageView = v .findViewById (R .id .ImageView_image );
327330 mImageView .setScaleType (ImageView .ScaleType .MATRIX );
328331
329- mCropOverlayView = ( CropOverlayView ) v .findViewById (R .id .CropOverlayView );
332+ mCropOverlayView = v .findViewById (R .id .CropOverlayView );
330333 mCropOverlayView .setCropWindowChangeListener (
331334 new CropOverlayView .CropWindowChangeListener () {
332335 @ Override
@@ -344,7 +347,7 @@ public void onCropWindowChanged(boolean inProgress) {
344347 });
345348 mCropOverlayView .setInitialAttributeValues (options );
346349
347- mProgressBar = ( ProgressBar ) v .findViewById (R .id .CropProgressBar );
350+ mProgressBar = v .findViewById (R .id .CropProgressBar );
348351 setProgressBarVisibility ();
349352 }
350353
@@ -1727,7 +1730,7 @@ private void applyImageMatrix(float width, float height, boolean center, boolean
17271730 /**
17281731 * Adjust the given image rectangle by image transformation matrix to know the final rectangle of
17291732 * the image.<br>
1730- * To get the proper rectangle it must be first reset to orginal image rectangle.
1733+ * To get the proper rectangle it must be first reset to original image rectangle.
17311734 */
17321735 private void mapImagePointsByImageMatrix () {
17331736 mImagePoints [0 ] = 0 ;
@@ -1739,6 +1742,15 @@ private void mapImagePointsByImageMatrix() {
17391742 mImagePoints [6 ] = 0 ;
17401743 mImagePoints [7 ] = mBitmap .getHeight ();
17411744 mImageMatrix .mapPoints (mImagePoints );
1745+ mScaleImagePoints [0 ] = 0 ;
1746+ mScaleImagePoints [1 ] = 0 ;
1747+ mScaleImagePoints [2 ] = 100 ;
1748+ mScaleImagePoints [3 ] = 0 ;
1749+ mScaleImagePoints [4 ] = 100 ;
1750+ mScaleImagePoints [5 ] = 100 ;
1751+ mScaleImagePoints [6 ] = 0 ;
1752+ mScaleImagePoints [7 ] = 100 ;
1753+ mImageMatrix .mapPoints (mScaleImagePoints );
17421754 }
17431755
17441756 /**
@@ -1795,9 +1807,9 @@ private void updateImageBounds(boolean clear) {
17951807 // Get the scale factor between the actual Bitmap dimensions and the displayed dimensions for
17961808 // width/height.
17971809 float scaleFactorWidth =
1798- mBitmap . getWidth () * mLoadedSampleSize / BitmapUtils .getRectWidth (mImagePoints );
1810+ 100f * mLoadedSampleSize / BitmapUtils .getRectWidth (mScaleImagePoints );
17991811 float scaleFactorHeight =
1800- mBitmap . getHeight () * mLoadedSampleSize / BitmapUtils .getRectHeight (mImagePoints );
1812+ 100f * mLoadedSampleSize / BitmapUtils .getRectHeight (mScaleImagePoints );
18011813 mCropOverlayView .setCropWindowLimits (
18021814 getWidth (), getHeight (), scaleFactorWidth , scaleFactorHeight );
18031815 }
0 commit comments