react-native-rectangle-doc-scanner 3.209.0 → 3.210.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.
|
@@ -434,20 +434,25 @@ class CameraController(
|
|
|
434
434
|
}
|
|
435
435
|
|
|
436
436
|
val rotationDegrees = getRotationDegrees()
|
|
437
|
+
val viewRect = RectF(0f, 0f, viewWidth.toFloat(), viewHeight.toFloat())
|
|
437
438
|
val bufferRect = if (rotationDegrees == 90 || rotationDegrees == 270) {
|
|
438
439
|
RectF(0f, 0f, previewSize.height.toFloat(), previewSize.width.toFloat())
|
|
439
440
|
} else {
|
|
440
441
|
RectF(0f, 0f, previewSize.width.toFloat(), previewSize.height.toFloat())
|
|
441
442
|
}
|
|
442
|
-
val viewRect = RectF(0f, 0f, viewWidth.toFloat(), viewHeight.toFloat())
|
|
443
443
|
val centerX = viewRect.centerX()
|
|
444
444
|
val centerY = viewRect.centerY()
|
|
445
445
|
|
|
446
446
|
bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
|
|
447
447
|
|
|
448
448
|
val matrix = Matrix()
|
|
449
|
-
//
|
|
450
|
-
matrix.setRectToRect(
|
|
449
|
+
// Map buffer to view, then scale to fill and rotate around the center.
|
|
450
|
+
matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.FILL)
|
|
451
|
+
val scale = kotlin.math.max(
|
|
452
|
+
viewWidth.toFloat() / bufferRect.width(),
|
|
453
|
+
viewHeight.toFloat() / bufferRect.height()
|
|
454
|
+
)
|
|
455
|
+
matrix.postScale(scale, scale, centerX, centerY)
|
|
451
456
|
if (rotationDegrees != 0) {
|
|
452
457
|
matrix.postRotate(rotationDegrees.toFloat(), centerX, centerY)
|
|
453
458
|
}
|
|
@@ -456,7 +461,7 @@ class CameraController(
|
|
|
456
461
|
Log.d(
|
|
457
462
|
TAG,
|
|
458
463
|
"[CAMERA2] transform view=${viewWidth}x${viewHeight} buffer=${previewSize.width}x${previewSize.height} " +
|
|
459
|
-
"rotation=$rotationDegrees"
|
|
464
|
+
"rotation=$rotationDegrees scale=$scale"
|
|
460
465
|
)
|
|
461
466
|
}
|
|
462
467
|
|
package/package.json
CHANGED