|
|
@@ -354,15 +354,17 @@ public class OperationPresenter extends BasePresenter<IOperationView> {
|
|
|
float heightD = 1.0f * rawBitmapHeight / mHeight;
|
|
|
boolean isPortraitPhoto = BigDecimal.valueOf(heightD).compareTo(BigDecimal.valueOf(widthD)) > 0;
|
|
|
if (isPortraitPhoto) {
|
|
|
- // 高的倍距大,以高为基准
|
|
|
- if (heightD > 1) {
|
|
|
+ // 高的倍距大
|
|
|
+ if (widthD >= 1) {
|
|
|
+ // 以宽为基准
|
|
|
// 图片宽要缩小到屏幕宽
|
|
|
- float pivot = 1.0f * rawBitmapHeight / mHeight;
|
|
|
+ float pivot = 1.0f * rawBitmapWidth / mWidth;
|
|
|
realLeft = (int) (mLeft * pivot);
|
|
|
- realTop = (int) (mTop * pivot);
|
|
|
+ realTop = (int) (mTop * pivot) + (rawBitmapHeight-mHeight)/2;
|
|
|
croppedBitmapWidth = (int) ((mRight - mLeft) * pivot);
|
|
|
croppedBitmapHeight = (int) ((mBottom - mTop) * pivot);
|
|
|
} else {
|
|
|
+ // 以高为基准
|
|
|
// 屏幕高要缩小到图片高
|
|
|
float pivot = 1.0f * mHeight / rawBitmapHeight;
|
|
|
realLeft = (int) (mLeft / pivot);
|
|
|
@@ -371,23 +373,24 @@ public class OperationPresenter extends BasePresenter<IOperationView> {
|
|
|
croppedBitmapHeight = (int) (1.0f * (mBottom - mTop) / pivot);
|
|
|
}
|
|
|
} else {
|
|
|
- // 宽的倍距大,以宽为基准
|
|
|
-// if (widthD > 1) {
|
|
|
-// // 图片高要缩小到屏幕高
|
|
|
-// float pivot = 1.0f * rawBitmapWidth / mWidth;
|
|
|
-// realLeft = (int) (mLeft * pivot);
|
|
|
-// realTop = (int) (mTop * pivot);
|
|
|
-// croppedBitmapWidth = (int) ((mRight - mLeft) * pivot);
|
|
|
-// croppedBitmapHeight = (int) ((mBottom - mTop) * pivot);
|
|
|
-// } else {
|
|
|
-//
|
|
|
-// }
|
|
|
- // 屏幕宽要缩小到图片宽
|
|
|
- float pivot = 1.0f * mWidth / rawBitmapWidth;
|
|
|
- realLeft = (int) (mLeft/pivot);
|
|
|
- realTop = (int) (mTop/pivot);
|
|
|
- croppedBitmapWidth = (int) (1.0f * (mRight - mLeft)/pivot);
|
|
|
- croppedBitmapHeight = (int) (1.0f * (mBottom - mTop)/pivot);
|
|
|
+ // 宽的倍距大
|
|
|
+ if (heightD >= 1) {
|
|
|
+ // 以高为基准
|
|
|
+ // 图片高要缩小到屏幕高,缩小了pivot倍
|
|
|
+ float pivot = 1.0f * rawBitmapHeight / mHeight;
|
|
|
+ realLeft = (int) (mLeft * pivot) + (rawBitmapWidth-mWidth)/2;
|
|
|
+ realTop = (int) (mTop * pivot);
|
|
|
+ croppedBitmapWidth = (int) ((mRight - mLeft) * pivot);
|
|
|
+ croppedBitmapHeight = (int) ((mBottom - mTop) * pivot);
|
|
|
+ } else {
|
|
|
+ // 以宽为基准
|
|
|
+ // 屏幕宽要缩小到图片宽
|
|
|
+ float pivot = 1.0f * mWidth / rawBitmapWidth;
|
|
|
+ realLeft = (int) (mLeft/pivot);
|
|
|
+ realTop = (int) (mTop/pivot);
|
|
|
+ croppedBitmapWidth = (int) (1.0f * (mRight - mLeft)/pivot);
|
|
|
+ croppedBitmapHeight = (int) (1.0f * (mBottom - mTop)/pivot);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -407,11 +410,11 @@ public class OperationPresenter extends BasePresenter<IOperationView> {
|
|
|
}
|
|
|
int max = rotatedBitmap.getWidth() > rotatedBitmap.getHeight() ? rotatedBitmap.getWidth() : rotatedBitmap.getHeight();
|
|
|
float multi = 1.0f;
|
|
|
- if (max > 2000) {
|
|
|
- multi = 1.0f * max / 2000 + 0.4f;
|
|
|
- } else if (multi > 1800) {
|
|
|
- multi = 1.1f;
|
|
|
- }
|
|
|
+// if (max > 2000) {
|
|
|
+// multi = 1.0f * max / 2000 + 0.4f;
|
|
|
+// } else if (multi > 1800) {
|
|
|
+// multi = 1.1f;
|
|
|
+// }
|
|
|
|
|
|
// 压缩图片
|
|
|
boolean saveCropSuccess = ImageUtil.saveBitmapFile(rotatedBitmap, file, multi);
|