react-native-rectangle-doc-scanner 7.8.0 → 7.9.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.
|
@@ -118,10 +118,10 @@ class CameraController(
|
|
|
118
118
|
return
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
+
// Always set the listener so we get size-change callbacks for transform updates.
|
|
122
|
+
previewView.surfaceTextureListener = textureListener
|
|
121
123
|
if (previewView.isAvailable) {
|
|
122
124
|
openCamera()
|
|
123
|
-
} else {
|
|
124
|
-
previewView.surfaceTextureListener = textureListener
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -150,8 +150,8 @@ class CameraController(
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
try {
|
|
153
|
-
//
|
|
154
|
-
val jpegOrientation =
|
|
153
|
+
// Match JPEG orientation to current device rotation and sensor orientation.
|
|
154
|
+
val jpegOrientation = computeRotationDegrees()
|
|
155
155
|
Log.d(TAG, "[CAPTURE] Setting JPEG_ORIENTATION to $jpegOrientation")
|
|
156
156
|
|
|
157
157
|
val requestBuilder = device.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE).apply {
|
|
@@ -240,9 +240,10 @@ class CameraController(
|
|
|
240
240
|
val previewSizes = streamConfigMap.getOutputSizes(SurfaceTexture::class.java)
|
|
241
241
|
Log.d(TAG, "[CAMERA2] Available preview sizes: ${previewSizes?.take(10)?.joinToString { "${it.width}x${it.height}" }}")
|
|
242
242
|
|
|
243
|
-
//
|
|
244
|
-
previewSize = previewSizes
|
|
245
|
-
|
|
243
|
+
// Prefer a preview size that matches the view aspect to avoid letterboxing.
|
|
244
|
+
previewSize = chooseBestSize(previewSizes, viewAspect, null, preferClosestAspect = true)
|
|
245
|
+
?: previewSizes?.maxByOrNull { it.width * it.height }
|
|
246
|
+
Log.d(TAG, "[CAMERA2] Selected preview size: ${previewSize?.width}x${previewSize?.height}")
|
|
246
247
|
|
|
247
248
|
val previewAspect = previewSize?.let { it.width.toDouble() / it.height.toDouble() } ?: viewAspect
|
|
248
249
|
val analysisSizes = streamConfigMap.getOutputSizes(ImageFormat.YUV_420_888)
|
|
@@ -648,11 +649,11 @@ class CameraController(
|
|
|
648
649
|
private fun rotateAndMirror(bitmap: Bitmap, rotationDegrees: Int, mirror: Boolean): Bitmap {
|
|
649
650
|
Log.d(TAG, "[ROTATE_MIRROR] rotationDegrees=$rotationDegrees mirror=$mirror bitmap=${bitmap.width}x${bitmap.height}")
|
|
650
651
|
|
|
651
|
-
// JPEG_ORIENTATION is already set
|
|
652
|
-
// We only need to apply mirror for front camera
|
|
652
|
+
// JPEG_ORIENTATION is already set, so the image should already be rotated correctly.
|
|
653
|
+
// We only need to apply mirror for front camera.
|
|
653
654
|
if (!mirror) {
|
|
654
|
-
// Back camera: no additional processing needed since JPEG_ORIENTATION handles rotation
|
|
655
|
-
Log.d(TAG, "[ROTATE_MIRROR] Back camera: returning bitmap as-is (JPEG_ORIENTATION
|
|
655
|
+
// Back camera: no additional processing needed since JPEG_ORIENTATION handles rotation.
|
|
656
|
+
Log.d(TAG, "[ROTATE_MIRROR] Back camera: returning bitmap as-is (JPEG_ORIENTATION already applied)")
|
|
656
657
|
return bitmap
|
|
657
658
|
}
|
|
658
659
|
|