Skip to content

Commit

Permalink
Merge branch 'master' into feature/non_native
Browse files Browse the repository at this point in the history
  • Loading branch information
shliama committed Sep 8, 2016
2 parents 09573d7 + e73f98e commit dbd6321
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ucrop/src/main/java/com/yalantis/ucrop/view/CropImageView.java
Original file line number Diff line number Diff line change
Expand Up @@ -479,11 +479,16 @@ private void setupInitialImagePosition(float drawableWidth, float drawableHeight
float cropRectWidth = mCropRect.width();
float cropRectHeight = mCropRect.height();

float tw = (cropRectWidth - drawableWidth * mMinScale) / 2.0f + mCropRect.left;
float th = (cropRectHeight - drawableHeight * mMinScale) / 2.0f + mCropRect.top;
float widthScale = mCropRect.width() / drawableWidth;
float heightScale = mCropRect.height() / drawableHeight;

float initialMinScale = Math.max(widthScale, heightScale);

float tw = (cropRectWidth - drawableWidth * initialMinScale) / 2.0f + mCropRect.left;
float th = (cropRectHeight - drawableHeight * initialMinScale) / 2.0f + mCropRect.top;

mCurrentImageMatrix.reset();
mCurrentImageMatrix.postScale(mMinScale, mMinScale);
mCurrentImageMatrix.postScale(initialMinScale, initialMinScale);
mCurrentImageMatrix.postTranslate(tw, th);
setImageMatrix(mCurrentImageMatrix);
}
Expand Down

0 comments on commit dbd6321

Please sign in to comment.