react-native-rectangle-doc-scanner 7.12.0 → 7.14.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.
@@ -484,7 +484,12 @@ class CameraController(
484
484
  val bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.size)
485
485
  ?: throw IllegalStateException("Failed to decode JPEG")
486
486
 
487
- val rotation = if (exifRotation != 0) exifRotation else computeRotationDegrees()
487
+ val computedRotation = computeRotationDegrees()
488
+ val rotation = if (exifRotation == 0 || exifRotation != computedRotation) {
489
+ computedRotation
490
+ } else {
491
+ exifRotation
492
+ }
488
493
  val rotated = rotateAndMirror(bitmap, rotation, useFrontCamera)
489
494
  val photoFile = File(pending.outputDirectory, "doc_scan_${System.currentTimeMillis()}.jpg")
490
495
  FileOutputStream(photoFile).use { out ->
@@ -554,20 +559,24 @@ class CameraController(
554
559
 
555
560
  val matrix = Matrix()
556
561
  val viewRect = RectF(0f, 0f, viewWidth, viewHeight)
557
- val bufferRect = RectF(0f, 0f, preview.height.toFloat(), preview.width.toFloat())
562
+ val bufferRect = if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
563
+ RectF(0f, 0f, preview.height.toFloat(), preview.width.toFloat())
564
+ } else {
565
+ RectF(0f, 0f, preview.width.toFloat(), preview.height.toFloat())
566
+ }
558
567
  val centerX = viewRect.centerX()
559
568
  val centerY = viewRect.centerY()
560
569
 
561
- if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
562
- bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
563
- matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.CENTER)
564
- val rotateDegrees = if (rotation == Surface.ROTATION_90) -90f else 90f
565
- matrix.postRotate(rotateDegrees, centerX, centerY)
566
- } else {
567
- matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.CENTER)
568
- if (rotation == Surface.ROTATION_180) {
569
- matrix.postRotate(180f, centerX, centerY)
570
+ bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
571
+ matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.FILL)
572
+ if (rotation != Surface.ROTATION_0) {
573
+ val rotateDegrees = when (rotation) {
574
+ Surface.ROTATION_90 -> -90f
575
+ Surface.ROTATION_180 -> 180f
576
+ Surface.ROTATION_270 -> 90f
577
+ else -> 0f
570
578
  }
579
+ matrix.postRotate(rotateDegrees, centerX, centerY)
571
580
  }
572
581
 
573
582
  previewView.setTransform(matrix)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "7.12.0",
3
+ "version": "7.14.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",