@@ -622,12 +622,14 @@ public Uri getImageUri() {
622
622
* @return a Rect instance dimensions of the source Bitmap
623
623
*/
624
624
public Rect getWholeImageRect () {
625
- if (mBitmap == null ) {
625
+ int loadedSampleSize = mLoadedSampleSize ;
626
+ Bitmap bitmap = mBitmap ;
627
+ if (bitmap == null ) {
626
628
return null ;
627
629
}
628
-
629
- int orgWidth = mBitmap .getWidth () * mLoadedSampleSize ;
630
- int orgHeight = mBitmap .getHeight () * mLoadedSampleSize ;
630
+
631
+ int orgWidth = bitmap .getWidth () * loadedSampleSize ;
632
+ int orgHeight = bitmap .getHeight () * loadedSampleSize ;
631
633
return new Rect (0 , 0 , orgWidth , orgHeight );
632
634
}
633
635
@@ -638,20 +640,21 @@ public Rect getWholeImageRect() {
638
640
* @return a Rect instance containing cropped area boundaries of the source Bitmap
639
641
*/
640
642
public Rect getCropRect () {
641
- if (mBitmap != null ) {
643
+ int loadedSampleSize = mLoadedSampleSize ;
644
+ Bitmap bitmap = mBitmap ;
645
+ if (bitmap == null ) {
646
+ return null ;
647
+ }
642
648
643
- // get the points of the crop rectangle adjusted to source bitmap
644
- float [] points = getCropPoints ();
649
+ // get the points of the crop rectangle adjusted to source bitmap
650
+ float [] points = getCropPoints ();
645
651
646
- int orgWidth = mBitmap .getWidth () * mLoadedSampleSize ;
647
- int orgHeight = mBitmap .getHeight () * mLoadedSampleSize ;
652
+ int orgWidth = bitmap .getWidth () * loadedSampleSize ;
653
+ int orgHeight = bitmap .getHeight () * loadedSampleSize ;
648
654
649
- // get the rectangle for the points (it may be larger than original if rotation is not stright)
650
- return BitmapUtils .getRectFromPoints (points , orgWidth , orgHeight ,
651
- mCropOverlayView .isFixAspectRatio (), mCropOverlayView .getAspectRatioX (), mCropOverlayView .getAspectRatioY ());
652
- } else {
653
- return null ;
654
- }
655
+ // get the rectangle for the points (it may be larger than original if rotation is not stright)
656
+ return BitmapUtils .getRectFromPoints (points , orgWidth , orgHeight ,
657
+ mCropOverlayView .isFixAspectRatio (), mCropOverlayView .getAspectRatioX (), mCropOverlayView .getAspectRatioY ());
655
658
}
656
659
657
660
/**
@@ -1161,7 +1164,8 @@ private void clearImageInt() {
1161
1164
* @param saveCompressQuality if saveUri is given, the given quality will be used for the compression.
1162
1165
*/
1163
1166
public void startCropWorkerTask (int reqWidth , int reqHeight , RequestSizeOptions options , Uri saveUri , Bitmap .CompressFormat saveCompressFormat , int saveCompressQuality ) {
1164
- if (mBitmap != null ) {
1167
+ Bitmap bitmap = mBitmap ;
1168
+ if (bitmap != null ) {
1165
1169
mImageView .clearAnimation ();
1166
1170
1167
1171
BitmapCroppingWorkerTask currentTask = mBitmapCroppingWorkerTask != null ? mBitmapCroppingWorkerTask .get () : null ;
@@ -1173,16 +1177,16 @@ public void startCropWorkerTask(int reqWidth, int reqHeight, RequestSizeOptions
1173
1177
reqWidth = options != RequestSizeOptions .NONE ? reqWidth : 0 ;
1174
1178
reqHeight = options != RequestSizeOptions .NONE ? reqHeight : 0 ;
1175
1179
1176
- int orgWidth = mBitmap .getWidth () * mLoadedSampleSize ;
1177
- int orgHeight = mBitmap .getHeight () * mLoadedSampleSize ;
1180
+ int orgWidth = bitmap .getWidth () * mLoadedSampleSize ;
1181
+ int orgHeight = bitmap .getHeight () * mLoadedSampleSize ;
1178
1182
if (mLoadedImageUri != null && (mLoadedSampleSize > 1 || options == RequestSizeOptions .SAMPLING )) {
1179
1183
mBitmapCroppingWorkerTask = new WeakReference <>(new BitmapCroppingWorkerTask (this , mLoadedImageUri , getCropPoints (),
1180
1184
mDegreesRotated , orgWidth , orgHeight ,
1181
1185
mCropOverlayView .isFixAspectRatio (), mCropOverlayView .getAspectRatioX (), mCropOverlayView .getAspectRatioY (),
1182
1186
reqWidth , reqHeight , mFlipHorizontally , mFlipVertically , options ,
1183
1187
saveUri , saveCompressFormat , saveCompressQuality ));
1184
1188
} else {
1185
- mBitmapCroppingWorkerTask = new WeakReference <>(new BitmapCroppingWorkerTask (this , mBitmap , getCropPoints (), mDegreesRotated ,
1189
+ mBitmapCroppingWorkerTask = new WeakReference <>(new BitmapCroppingWorkerTask (this , bitmap , getCropPoints (), mDegreesRotated ,
1186
1190
mCropOverlayView .isFixAspectRatio (), mCropOverlayView .getAspectRatioX (), mCropOverlayView .getAspectRatioY (),
1187
1191
reqWidth , reqHeight , mFlipHorizontally , mFlipVertically , options ,
1188
1192
saveUri , saveCompressFormat , saveCompressQuality ));
0 commit comments