Skip to content

Commit

Permalink
Support float for sample size
Browse files Browse the repository at this point in the history
  • Loading branch information
koujm committed Sep 9, 2017
1 parent d56ef18 commit bbdbf4e
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public class CropImageView extends FrameLayout {
/**
* The sample size the image was loaded by if was loaded by URI
*/
private int mLoadedSampleSize = 1;
private float mLoadedSampleSize = 1f;

/**
* The current zoom level to to scale the cropping image
Expand Down Expand Up @@ -518,8 +518,8 @@ public Rect getWholeImageRect() {
return null;
}

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

Expand All @@ -535,8 +535,8 @@ public Rect getCropRect() {
// 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 = (int) (mBitmap.getWidth() * mLoadedSampleSize);
int orgHeight = (int) (mBitmap.getHeight() * mLoadedSampleSize);

// get the rectangle for the points (it may be larger than original if rotation is
// not stright)
Expand Down Expand Up @@ -629,7 +629,7 @@ public void setImageBitmap(Bitmap bitmap) {
* @param loadSampleSize the sample size of bitmap
* @param degreesRotated the degrees bitmap should be rotated
*/
public void setImageBitmap(Bitmap bitmap, int loadSampleSize, int degreesRotated) {
public void setImageBitmap(Bitmap bitmap, float loadSampleSize, int degreesRotated) {
mCropOverlayView.setInitialCropWindowRect(null);
setBitmap(bitmap, loadSampleSize, degreesRotated);
}
Expand Down Expand Up @@ -743,7 +743,7 @@ public void flipImageVertically() {
* Optionally clear full if the bitmap is new, or partial clear if the bitmap has been
* manipulated.
*/
private void setBitmap(Bitmap bitmap, int loadSampleSize, int degreesRotated) {
private void setBitmap(Bitmap bitmap, float loadSampleSize, int degreesRotated) {
if (mBitmap == null || !mBitmap.equals(bitmap)) {

mImageView.clearAnimation();
Expand Down

0 comments on commit bbdbf4e

Please sign in to comment.