Skip to content

Commit

Permalink
fix ver doc and minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurHub committed Sep 1, 2017
1 parent a46d434 commit d5c5cbc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Android Image Cropper
1. Include the library

```
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.+'
compile 'com.theartofdev.edmodo:android-image-cropper:2.5.+'
```

Add permissions to manifest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.crop_image_activity);

mCropImageView = (CropImageView) findViewById(R.id.cropImageView);
mCropImageView = findViewById(R.id.cropImageView);

Bundle bundle = getIntent().getBundleExtra(CropImageOptions.BUNDLE_KEY);
mCropImageUri = bundle.getParcelable(CropImage.CROP_IMAGE_EXTRA_SOURCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,12 +622,14 @@ public Uri getImageUri() {
* @return a Rect instance dimensions of the source Bitmap
*/
public Rect getWholeImageRect() {
if (mBitmap == null) {
int loadedSampleSize = mLoadedSampleSize;
Bitmap bitmap = mBitmap;
if (bitmap == null) {
return null;
}
int orgWidth = mBitmap.getWidth() * mLoadedSampleSize;
int orgHeight = mBitmap.getHeight() * mLoadedSampleSize;

int orgWidth = bitmap.getWidth() * loadedSampleSize;
int orgHeight = bitmap.getHeight() * loadedSampleSize;
return new Rect(0, 0, orgWidth, orgHeight);
}

Expand All @@ -638,20 +640,21 @@ public Rect getWholeImageRect() {
* @return a Rect instance containing cropped area boundaries of the source Bitmap
*/
public Rect getCropRect() {
if (mBitmap != null) {
int loadedSampleSize = mLoadedSampleSize;
Bitmap bitmap = mBitmap;
if (bitmap == null) {
return null;
}

// get the points of the crop rectangle adjusted to source bitmap
float[] points = getCropPoints();
// get the points of the crop rectangle adjusted to source bitmap
float[] points = getCropPoints();

int orgWidth = mBitmap.getWidth() * mLoadedSampleSize;
int orgHeight = mBitmap.getHeight() * mLoadedSampleSize;
int orgWidth = bitmap.getWidth() * loadedSampleSize;
int orgHeight = bitmap.getHeight() * loadedSampleSize;

// get the rectangle for the points (it may be larger than original if rotation is not stright)
return BitmapUtils.getRectFromPoints(points, orgWidth, orgHeight,
mCropOverlayView.isFixAspectRatio(), mCropOverlayView.getAspectRatioX(), mCropOverlayView.getAspectRatioY());
} else {
return null;
}
// get the rectangle for the points (it may be larger than original if rotation is not stright)
return BitmapUtils.getRectFromPoints(points, orgWidth, orgHeight,
mCropOverlayView.isFixAspectRatio(), mCropOverlayView.getAspectRatioX(), mCropOverlayView.getAspectRatioY());
}

/**
Expand Down Expand Up @@ -1161,7 +1164,8 @@ private void clearImageInt() {
* @param saveCompressQuality if saveUri is given, the given quality will be used for the compression.
*/
public void startCropWorkerTask(int reqWidth, int reqHeight, RequestSizeOptions options, Uri saveUri, Bitmap.CompressFormat saveCompressFormat, int saveCompressQuality) {
if (mBitmap != null) {
Bitmap bitmap = mBitmap;
if (bitmap != null) {
mImageView.clearAnimation();

BitmapCroppingWorkerTask currentTask = mBitmapCroppingWorkerTask != null ? mBitmapCroppingWorkerTask.get() : null;
Expand All @@ -1173,16 +1177,16 @@ public void startCropWorkerTask(int reqWidth, int reqHeight, RequestSizeOptions
reqWidth = options != RequestSizeOptions.NONE ? reqWidth : 0;
reqHeight = options != RequestSizeOptions.NONE ? reqHeight : 0;

int orgWidth = mBitmap.getWidth() * mLoadedSampleSize;
int orgHeight = mBitmap.getHeight() * mLoadedSampleSize;
int orgWidth = bitmap.getWidth() * mLoadedSampleSize;
int orgHeight = bitmap.getHeight() * mLoadedSampleSize;
if (mLoadedImageUri != null && (mLoadedSampleSize > 1 || options == RequestSizeOptions.SAMPLING)) {
mBitmapCroppingWorkerTask = new WeakReference<>(new BitmapCroppingWorkerTask(this, mLoadedImageUri, getCropPoints(),
mDegreesRotated, orgWidth, orgHeight,
mCropOverlayView.isFixAspectRatio(), mCropOverlayView.getAspectRatioX(), mCropOverlayView.getAspectRatioY(),
reqWidth, reqHeight, mFlipHorizontally, mFlipVertically, options,
saveUri, saveCompressFormat, saveCompressQuality));
} else {
mBitmapCroppingWorkerTask = new WeakReference<>(new BitmapCroppingWorkerTask(this, mBitmap, getCropPoints(), mDegreesRotated,
mBitmapCroppingWorkerTask = new WeakReference<>(new BitmapCroppingWorkerTask(this, bitmap, getCropPoints(), mDegreesRotated,
mCropOverlayView.isFixAspectRatio(), mCropOverlayView.getAspectRatioX(), mCropOverlayView.getAspectRatioY(),
reqWidth, reqHeight, mFlipHorizontally, mFlipVertically, options,
saveUri, saveCompressFormat, saveCompressQuality));
Expand Down

0 comments on commit d5c5cbc

Please sign in to comment.