Browse Source

正确比例

詹子聪 5 năm trước cách đây
mục cha
commit
f34d3df9e2

+ 4 - 4
app/src/main/java/com/miekir/ocr/ui/OperationPresenter.java

@@ -354,10 +354,10 @@ 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 (widthD > 1) {
                         // 图片宽要缩小到屏幕宽
-                        float pivot = 1.0f * rawBitmapWidth / mWidth;
+                        float pivot = 1.0f * rawBitmapHeight / mHeight;
                         realLeft = (int) (mLeft * pivot);
                         realTop = (int) (mTop * pivot);
                         croppedBitmapWidth = (int) ((mRight - mLeft) * pivot);
@@ -371,10 +371,10 @@ public class OperationPresenter extends BasePresenter<IOperationView> {
                         croppedBitmapHeight = (int) (1.0f * (mBottom - mTop) / pivot);
                     }
                 } else {
-                    // 宽的倍距大,以为基准
+                    // 宽的倍距大,以为基准
                     if (heightD > 1) {
                         // 图片高要缩小到屏幕高
-                        float pivot = 1.0f * rawBitmapHeight / mHeight;
+                        float pivot = 1.0f * rawBitmapWidth / mWidth;
                         realLeft = (int) (mLeft * pivot);
                         realTop = (int) (mTop * pivot);
                         croppedBitmapWidth = (int) ((mRight - mLeft) * pivot);