react-native-rectangle-doc-scanner 7.18.0 → 7.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,7 +8,6 @@ import android.graphics.BitmapFactory
|
|
|
8
8
|
import android.graphics.Matrix
|
|
9
9
|
import android.graphics.SurfaceTexture
|
|
10
10
|
import android.graphics.Rect
|
|
11
|
-
import android.graphics.RectF
|
|
12
11
|
import android.graphics.ImageFormat
|
|
13
12
|
import android.hardware.camera2.CameraCaptureSession
|
|
14
13
|
import android.hardware.camera2.CameraCharacteristics
|
|
@@ -555,30 +554,25 @@ class CameraController(
|
|
|
555
554
|
val viewHeight = previewView.height.toFloat()
|
|
556
555
|
val preview = previewSize ?: return
|
|
557
556
|
if (viewWidth == 0f || viewHeight == 0f) return
|
|
558
|
-
val
|
|
559
|
-
val rotationDegrees = displayRotationDegrees()
|
|
557
|
+
val rotationDegrees = computeRotationDegrees()
|
|
560
558
|
Log.d(TAG, "[TRANSFORM] rotation=$rotationDegrees view=${viewWidth}x${viewHeight} preview=${preview.width}x${preview.height}")
|
|
561
559
|
|
|
562
560
|
val matrix = Matrix()
|
|
563
561
|
val centerX = viewWidth / 2f
|
|
564
562
|
val centerY = viewHeight / 2f
|
|
565
|
-
val isSwapped =
|
|
563
|
+
val isSwapped = rotationDegrees == 90 || rotationDegrees == 270
|
|
566
564
|
val bufferWidth = if (isSwapped) preview.height.toFloat() else preview.width.toFloat()
|
|
567
565
|
val bufferHeight = if (isSwapped) preview.width.toFloat() else preview.height.toFloat()
|
|
568
|
-
val
|
|
569
|
-
val
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
Surface.ROTATION_270 -> 90f
|
|
579
|
-
else -> 0f
|
|
580
|
-
}
|
|
581
|
-
matrix.postRotate(rotateDegrees, centerX, centerY)
|
|
566
|
+
val scale = max(viewWidth / bufferWidth, viewHeight / bufferHeight)
|
|
567
|
+
val scaledWidth = bufferWidth * scale
|
|
568
|
+
val scaledHeight = bufferHeight * scale
|
|
569
|
+
val dx = (viewWidth - scaledWidth) / 2f
|
|
570
|
+
val dy = (viewHeight - scaledHeight) / 2f
|
|
571
|
+
matrix.setScale(scale, scale)
|
|
572
|
+
matrix.postTranslate(dx, dy)
|
|
573
|
+
|
|
574
|
+
if (rotationDegrees != 0) {
|
|
575
|
+
matrix.postRotate(rotationDegrees.toFloat(), centerX, centerY)
|
|
582
576
|
}
|
|
583
577
|
|
|
584
578
|
previewView.setTransform(matrix)
|