react-native-rectangle-doc-scanner 7.28.0 → 7.30.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.
|
@@ -246,8 +246,9 @@ class CameraController(
|
|
|
246
246
|
val previewSizes = streamConfigMap.getOutputSizes(SurfaceTexture::class.java)
|
|
247
247
|
Log.d(TAG, "[CAMERA2] Available preview sizes: ${previewSizes?.take(10)?.joinToString { "${it.width}x${it.height}" }}")
|
|
248
248
|
|
|
249
|
-
//
|
|
250
|
-
val
|
|
249
|
+
// Prefer 4:3 to match iOS FOV on phones; use view aspect on tablets to reduce crop.
|
|
250
|
+
val isTablet = context.resources.configuration.smallestScreenWidthDp >= 600
|
|
251
|
+
val targetPreviewAspect = if (isTablet) viewAspect else 4.0 / 3.0
|
|
251
252
|
previewSize = chooseBestSize(previewSizes, targetPreviewAspect, null, preferClosestAspect = true)
|
|
252
253
|
?: chooseBestSize(previewSizes, viewAspect, null, preferClosestAspect = true)
|
|
253
254
|
?: previewSizes?.maxByOrNull { it.width * it.height }
|
|
@@ -564,27 +565,25 @@ class CameraController(
|
|
|
564
565
|
)
|
|
565
566
|
|
|
566
567
|
val matrix = Matrix()
|
|
567
|
-
val isSwapped = rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270
|
|
568
|
-
val bufferWidth = if (isSwapped) preview.height.toFloat() else preview.width.toFloat()
|
|
569
|
-
val bufferHeight = if (isSwapped) preview.width.toFloat() else preview.height.toFloat()
|
|
570
568
|
val viewRect = RectF(0f, 0f, viewWidth, viewHeight)
|
|
571
|
-
val bufferRect = RectF(0f, 0f, bufferWidth, bufferHeight)
|
|
572
569
|
val centerX = viewRect.centerX()
|
|
573
570
|
val centerY = viewRect.centerY()
|
|
574
571
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
matrix.
|
|
572
|
+
if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
|
|
573
|
+
val bufferRect = RectF(0f, 0f, preview.height.toFloat(), preview.width.toFloat())
|
|
574
|
+
bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
|
|
575
|
+
matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL)
|
|
576
|
+
val scale = max(viewHeight / preview.height.toFloat(), viewWidth / preview.width.toFloat())
|
|
577
|
+
matrix.postScale(scale, scale, centerX, centerY)
|
|
578
|
+
matrix.postRotate(90f * (rotation - 2), centerX, centerY)
|
|
579
|
+
} else if (rotation == Surface.ROTATION_180) {
|
|
580
|
+
matrix.postRotate(180f, centerX, centerY)
|
|
581
|
+
} else {
|
|
582
|
+
val bufferRect = RectF(0f, 0f, preview.width.toFloat(), preview.height.toFloat())
|
|
583
|
+
bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
|
|
584
|
+
matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL)
|
|
585
|
+
val scale = max(viewWidth / preview.width.toFloat(), viewHeight / preview.height.toFloat())
|
|
586
|
+
matrix.postScale(scale, scale, centerX, centerY)
|
|
588
587
|
}
|
|
589
588
|
|
|
590
589
|
previewView.setTransform(matrix)
|