react-native-rectangle-doc-scanner 7.40.0 → 7.42.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.
@@ -575,26 +575,25 @@ class CameraController(
575
575
 
576
576
  val matrix = Matrix()
577
577
  val viewRect = RectF(0f, 0f, viewWidth, viewHeight)
578
- val bufferRect = if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
579
- RectF(0f, 0f, preview.height.toFloat(), preview.width.toFloat())
580
- } else {
581
- RectF(0f, 0f, preview.width.toFloat(), preview.height.toFloat())
582
- }
578
+ val bufferRect = RectF(0f, 0f, preview.width.toFloat(), preview.height.toFloat())
583
579
  val centerX = viewRect.centerX()
584
580
  val centerY = viewRect.centerY()
585
581
 
586
- bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
587
- matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL)
588
- val scale = max(viewWidth / bufferRect.width(), viewHeight / bufferRect.height())
589
- matrix.postScale(scale, scale, centerX, centerY)
590
-
591
- when (rotation) {
592
- Surface.ROTATION_90, Surface.ROTATION_270 -> {
593
- matrix.postRotate(90f * (rotation - 2), centerX, centerY)
594
- }
595
- Surface.ROTATION_180 -> {
596
- matrix.postRotate(180f, centerX, centerY)
597
- }
582
+ if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
583
+ val swappedBufferRect = RectF(0f, 0f, preview.height.toFloat(), preview.width.toFloat())
584
+ swappedBufferRect.offset(centerX - swappedBufferRect.centerX(), centerY - swappedBufferRect.centerY())
585
+ matrix.setRectToRect(viewRect, swappedBufferRect, Matrix.ScaleToFit.CENTER)
586
+ val scale = max(viewHeight / preview.height.toFloat(), viewWidth / preview.width.toFloat())
587
+ matrix.postScale(scale, scale, centerX, centerY)
588
+ matrix.postRotate(90f * (rotation - 2), centerX, centerY)
589
+ } else if (rotation == Surface.ROTATION_180) {
590
+ matrix.postRotate(180f, centerX, centerY)
591
+ } else {
592
+ val scale = max(viewWidth / preview.width.toFloat(), viewHeight / preview.height.toFloat())
593
+ val scaledWidth = preview.width.toFloat() * scale
594
+ val scaledHeight = preview.height.toFloat() * scale
595
+ matrix.setScale(scale, scale)
596
+ matrix.postTranslate((viewWidth - scaledWidth) / 2f, (viewHeight - scaledHeight) / 2f)
598
597
  }
599
598
 
600
599
  previewView.setTransform(matrix)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "7.40.0",
3
+ "version": "7.42.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",