react-native-rectangle-doc-scanner 3.236.0 → 3.237.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.
|
@@ -7,6 +7,7 @@ import android.graphics.Bitmap
|
|
|
7
7
|
import android.graphics.BitmapFactory
|
|
8
8
|
import android.graphics.Matrix
|
|
9
9
|
import android.graphics.SurfaceTexture
|
|
10
|
+
import android.graphics.RectF
|
|
10
11
|
import android.graphics.ImageFormat
|
|
11
12
|
import android.hardware.camera2.CameraCaptureSession
|
|
12
13
|
import android.hardware.camera2.CameraCharacteristics
|
|
@@ -445,12 +446,17 @@ class CameraController(
|
|
|
445
446
|
val bufferWidth = if (rotation == 90 || rotation == 270) preview.height.toFloat() else preview.width.toFloat()
|
|
446
447
|
val bufferHeight = if (rotation == 90 || rotation == 270) preview.width.toFloat() else preview.height.toFloat()
|
|
447
448
|
|
|
448
|
-
val
|
|
449
|
+
val viewRect = RectF(0f, 0f, viewWidth, viewHeight)
|
|
450
|
+
val bufferRect = RectF(0f, 0f, bufferWidth, bufferHeight)
|
|
451
|
+
val centerX = viewRect.centerX()
|
|
452
|
+
val centerY = viewRect.centerY()
|
|
453
|
+
|
|
449
454
|
val matrix = Matrix()
|
|
450
|
-
|
|
451
|
-
|
|
455
|
+
bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
|
|
456
|
+
matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL)
|
|
452
457
|
|
|
453
|
-
|
|
458
|
+
val scale = max(viewWidth / bufferWidth, viewHeight / bufferHeight)
|
|
459
|
+
matrix.postScale(scale, scale, centerX, centerY)
|
|
454
460
|
matrix.postRotate(rotation.toFloat(), centerX, centerY)
|
|
455
461
|
previewView.setTransform(matrix)
|
|
456
462
|
}
|
package/package.json
CHANGED