Skip to content

Commit

Permalink
update to android studio 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur committed Apr 9, 2016
1 parent 9dcb78b commit 4b34389
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ For more information, see the [linked Github Wiki page](https://github.com/Arthu
- [Android Image Cropper async support and custom progress UI](http://theartofdev.com/2016/01/15/android-image-cropper-async-support-and-custom-progress-ui/)

## Change log
*1.2.5*
* Fix off-by-1 error in cropping rectangle, double verify width == height for 1:1 fixed aspect ratio.

*1.2.4*
* add fallback in crop to use `BitmapFactory` when `BitmapRegionDecoder` fails
* Added fallback in crop to use `BitmapFactory` when `BitmapRegionDecoder` fails

*1.2.3*
* Fix `getActualCropRect` to adjust by sampling size for images loaded from URI.
Expand Down
2 changes: 1 addition & 1 deletion cropper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ apply plugin: 'maven-publish'
ext {
PUBLISH_GROUP_ID = 'com.theartofdev.edmodo'
PUBLISH_ARTIFACT_ID = 'android-image-cropper'
PUBLISH_VERSION = '1.2.4'
PUBLISH_VERSION = '1.2.5'
// gradlew clean build generateRelease
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,21 @@ public Rect getActualCropRect() {
float actualCropBottom = actualCropTop + displayedCropHeight * scaleFactor.second;

// Correct for floating point errors. Crop rect boundaries should not exceed the source Bitmap bounds.
actualCropLeft = Math.max(0f, actualCropLeft) * mLoadedSampleSize;
actualCropTop = Math.max(0f, actualCropTop) * mLoadedSampleSize;
actualCropRight = Math.min(mBitmap.getWidth(), actualCropRight) * mLoadedSampleSize;
actualCropBottom = Math.min(mBitmap.getHeight(), actualCropBottom) * mLoadedSampleSize;
actualCropLeft = Math.round(Math.max(0f, actualCropLeft) * mLoadedSampleSize);
actualCropTop = Math.round(Math.max(0f, actualCropTop) * mLoadedSampleSize);
actualCropRight = Math.round(Math.min(mBitmap.getWidth(), actualCropRight) * mLoadedSampleSize);
actualCropBottom = Math.round(Math.min(mBitmap.getHeight(), actualCropBottom) * mLoadedSampleSize);

// extra cehck to be sure that width and height are equal if 1:1 fixed aspect ratio is requested
if (mCropOverlayView.isFixAspectRatio()
&& mCropOverlayView.getAspectRatioX() == mCropOverlayView.getAspectRatioY()
&& actualCropBottom - actualCropTop != actualCropRight - actualCropLeft) {
if (actualCropBottom - actualCropTop > actualCropRight - actualCropLeft) {
actualCropBottom--;
} else {
actualCropRight--;
}
}

return new Rect((int) actualCropLeft, (int) actualCropTop, (int) actualCropRight, (int) actualCropBottom);
} else {
Expand Down

0 comments on commit 4b34389

Please sign in to comment.