react-native-rectangle-doc-scanner 3.208.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,39 +434,34 @@ class CameraController(
|
|
|
434
434
|
}
|
|
435
435
|
|
|
436
436
|
val rotationDegrees = getRotationDegrees()
|
|
437
|
-
val
|
|
438
|
-
val
|
|
439
|
-
|
|
440
|
-
bufferHeight
|
|
437
|
+
val viewRect = RectF(0f, 0f, viewWidth.toFloat(), viewHeight.toFloat())
|
|
438
|
+
val bufferRect = if (rotationDegrees == 90 || rotationDegrees == 270) {
|
|
439
|
+
RectF(0f, 0f, previewSize.height.toFloat(), previewSize.width.toFloat())
|
|
441
440
|
} else {
|
|
442
|
-
|
|
443
|
-
}
|
|
444
|
-
val rotatedBufferHeight = if (rotationDegrees == 90 || rotationDegrees == 270) {
|
|
445
|
-
bufferWidth
|
|
446
|
-
} else {
|
|
447
|
-
bufferHeight
|
|
441
|
+
RectF(0f, 0f, previewSize.width.toFloat(), previewSize.height.toFloat())
|
|
448
442
|
}
|
|
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
|
+
// 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)
|
|
459
456
|
if (rotationDegrees != 0) {
|
|
460
|
-
matrix.postRotate(rotationDegrees.toFloat())
|
|
457
|
+
matrix.postRotate(rotationDegrees.toFloat(), centerX, centerY)
|
|
461
458
|
}
|
|
462
|
-
matrix.postScale(scale, scale)
|
|
463
|
-
matrix.postTranslate(viewWidth / 2f, viewHeight / 2f)
|
|
464
459
|
|
|
465
460
|
previewView.setTransform(matrix)
|
|
466
461
|
Log.d(
|
|
467
462
|
TAG,
|
|
468
|
-
"[CAMERA2] transform view=${viewWidth}x${viewHeight} buffer=${
|
|
469
|
-
"
|
|
463
|
+
"[CAMERA2] transform view=${viewWidth}x${viewHeight} buffer=${previewSize.width}x${previewSize.height} " +
|
|
464
|
+
"rotation=$rotationDegrees scale=$scale"
|
|
470
465
|
)
|
|
471
466
|
}
|
|
472
467
|
|
package/package.json
CHANGED