react-native-rectangle-doc-scanner 3.199.0 → 3.200.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.
|
@@ -366,25 +366,32 @@ class CameraController(
|
|
|
366
366
|
}
|
|
367
367
|
|
|
368
368
|
val rotationDegrees = getRotationDegrees()
|
|
369
|
-
val
|
|
370
|
-
val
|
|
371
|
-
val
|
|
372
|
-
|
|
369
|
+
val bufferWidth = previewSize.width.toFloat()
|
|
370
|
+
val bufferHeight = previewSize.height.toFloat()
|
|
371
|
+
val rotatedBufferWidth = if (rotationDegrees == 90 || rotationDegrees == 270) {
|
|
372
|
+
bufferHeight
|
|
373
|
+
} else {
|
|
374
|
+
bufferWidth
|
|
375
|
+
}
|
|
376
|
+
val rotatedBufferHeight = if (rotationDegrees == 90 || rotationDegrees == 270) {
|
|
377
|
+
bufferWidth
|
|
373
378
|
} else {
|
|
374
|
-
|
|
379
|
+
bufferHeight
|
|
375
380
|
}
|
|
376
|
-
val centerX = viewRect.centerX()
|
|
377
|
-
val centerY = viewRect.centerY()
|
|
378
381
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
+
val scale = kotlin.math.min(
|
|
383
|
+
viewWidth.toFloat() / rotatedBufferWidth,
|
|
384
|
+
viewHeight.toFloat() / rotatedBufferHeight
|
|
385
|
+
)
|
|
382
386
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
+
val matrix = Matrix()
|
|
388
|
+
// Center buffer at origin, rotate, scale to fit, then move to view center.
|
|
389
|
+
matrix.postTranslate(-bufferWidth / 2f, -bufferHeight / 2f)
|
|
390
|
+
if (rotationDegrees != 0) {
|
|
391
|
+
matrix.postRotate(rotationDegrees.toFloat())
|
|
387
392
|
}
|
|
393
|
+
matrix.postScale(scale, scale)
|
|
394
|
+
matrix.postTranslate(viewWidth / 2f, viewHeight / 2f)
|
|
388
395
|
|
|
389
396
|
previewView.setTransform(matrix)
|
|
390
397
|
}
|
|
@@ -517,7 +524,11 @@ class CameraController(
|
|
|
517
524
|
|
|
518
525
|
val ratioFiltered = if (targetRatio != null) {
|
|
519
526
|
candidates.filter { size ->
|
|
520
|
-
val ratio =
|
|
527
|
+
val ratio = if (targetRatio < 1f) {
|
|
528
|
+
size.height.toFloat() / size.width.toFloat()
|
|
529
|
+
} else {
|
|
530
|
+
size.width.toFloat() / size.height.toFloat()
|
|
531
|
+
}
|
|
521
532
|
kotlin.math.abs(ratio - targetRatio) <= 0.05f
|
|
522
533
|
}
|
|
523
534
|
} else {
|
package/package.json
CHANGED