react-native-rectangle-doc-scanner 7.26.0 → 7.28.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.
|
@@ -572,7 +572,7 @@ class CameraController(
|
|
|
572
572
|
val centerX = viewRect.centerX()
|
|
573
573
|
val centerY = viewRect.centerY()
|
|
574
574
|
|
|
575
|
-
//
|
|
575
|
+
// Uniform scale to avoid stretching; then center-crop to fill the view.
|
|
576
576
|
matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.CENTER)
|
|
577
577
|
val scale = max(viewWidth / bufferWidth, viewHeight / bufferHeight)
|
|
578
578
|
matrix.postScale(scale, scale, centerX, centerY)
|
package/dist/DocScanner.js
CHANGED
|
@@ -627,7 +627,18 @@ const NativeScanner = (0, react_1.forwardRef)(({ onCapture, overlayColor = DEFAU
|
|
|
627
627
|
}, [capture]);
|
|
628
628
|
const handleRectangleDetect = (0, react_1.useCallback)((event) => {
|
|
629
629
|
const rectangleCoordinates = normalizeRectangle(event.rectangleCoordinates ?? null);
|
|
630
|
-
|
|
630
|
+
let rectangleOnScreen = normalizeRectangle(event.rectangleOnScreen ?? null);
|
|
631
|
+
const density = react_native_1.PixelRatio.get();
|
|
632
|
+
if (react_native_1.Platform.OS === 'android' &&
|
|
633
|
+
rectangleCoordinates &&
|
|
634
|
+
event.imageSize &&
|
|
635
|
+
event.previewSize &&
|
|
636
|
+
event.imageSize.width &&
|
|
637
|
+
event.imageSize.height &&
|
|
638
|
+
event.previewSize.width &&
|
|
639
|
+
event.previewSize.height) {
|
|
640
|
+
rectangleOnScreen = mapRectangleToView(rectangleCoordinates, event.imageSize.width, event.imageSize.height, event.previewSize.width, event.previewSize.height, density);
|
|
641
|
+
}
|
|
631
642
|
const payload = {
|
|
632
643
|
...event,
|
|
633
644
|
rectangleCoordinates,
|
package/package.json
CHANGED
package/src/DocScanner.tsx
CHANGED
|
@@ -874,7 +874,28 @@ const NativeScanner = forwardRef<DocScannerHandle, Props>(
|
|
|
874
874
|
const handleRectangleDetect = useCallback(
|
|
875
875
|
(event: RectangleEventPayload) => {
|
|
876
876
|
const rectangleCoordinates = normalizeRectangle(event.rectangleCoordinates ?? null);
|
|
877
|
-
|
|
877
|
+
let rectangleOnScreen = normalizeRectangle(event.rectangleOnScreen ?? null);
|
|
878
|
+
const density = PixelRatio.get();
|
|
879
|
+
|
|
880
|
+
if (
|
|
881
|
+
Platform.OS === 'android' &&
|
|
882
|
+
rectangleCoordinates &&
|
|
883
|
+
event.imageSize &&
|
|
884
|
+
event.previewSize &&
|
|
885
|
+
event.imageSize.width &&
|
|
886
|
+
event.imageSize.height &&
|
|
887
|
+
event.previewSize.width &&
|
|
888
|
+
event.previewSize.height
|
|
889
|
+
) {
|
|
890
|
+
rectangleOnScreen = mapRectangleToView(
|
|
891
|
+
rectangleCoordinates,
|
|
892
|
+
event.imageSize.width,
|
|
893
|
+
event.imageSize.height,
|
|
894
|
+
event.previewSize.width,
|
|
895
|
+
event.previewSize.height,
|
|
896
|
+
density,
|
|
897
|
+
);
|
|
898
|
+
}
|
|
878
899
|
|
|
879
900
|
const payload: RectangleDetectEvent = {
|
|
880
901
|
...event,
|