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