react-native-rectangle-doc-scanner 1.15.0 → 2.0.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.
@@ -0,0 +1,9 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(node:*)"
5
+ ],
6
+ "deny": [],
7
+ "ask": []
8
+ }
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "1.15.0",
3
+ "version": "2.0.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -2,6 +2,16 @@ diff --git a/node_modules/react-native-document-scanner/ios/IPDFCameraViewContro
2
2
  index 1234567..abcdefg 100644
3
3
  --- a/node_modules/react-native-document-scanner/ios/IPDFCameraViewController.m
4
4
  +++ b/node_modules/react-native-document-scanner/ios/IPDFCameraViewController.m
5
+ @@ -76,7 +76,7 @@
6
+ GLKView *view = [[GLKView alloc] initWithFrame:self.bounds];
7
+ view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
8
+ view.translatesAutoresizingMaskIntoConstraints = YES;
9
+ view.context = self.context;
10
+ - view.contentScaleFactor = 1.0f;
11
+ + view.contentScaleFactor = [UIScreen mainScreen].scale;
12
+ view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
13
+ [self insertSubview:view atIndex:0];
14
+ _glkView = view;
5
15
  @@ -115,7 +115,16 @@
6
16
 
7
17
  NSError *error = nil;
@@ -20,3 +30,57 @@ index 1234567..abcdefg 100644
20
30
  [session addInput:input];
21
31
 
22
32
  AVCaptureVideoDataOutput *dataOutput = [[AVCaptureVideoDataOutput alloc] init];
33
+ @@ -134,6 +143,8 @@
34
+ [session addOutput:dataOutput];
35
+
36
+ self.stillImageOutput = [[AVCaptureStillImageOutput alloc] init];
37
+ + // Use maximum quality for still image capture
38
+ + self.stillImageOutput.outputSettings = @{AVVideoCodecKey: AVVideoCodecJPEG};
39
+ [session addOutput:self.stillImageOutput];
40
+
41
+ AVCaptureConnection *connection = [dataOutput.connections firstObject];
42
+ @@ -381,10 +392,18 @@
43
+
44
+ [self.stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error)
45
+ {
46
+ - NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
47
+ + // Get the highest quality image data from sample buffer
48
+ + CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(imageSampleBuffer);
49
+ + CIImage *sourceImage = [CIImage imageWithCVPixelBuffer:imageBuffer];
50
+ +
51
+ + // Create high quality JPEG data
52
+ + CIContext *context = [CIContext context];
53
+ + NSData *imageData = [context JPEGRepresentationOfImage:sourceImage colorSpace:sourceImage.colorSpace options:@{(id)kCGImageDestinationLossyCompressionQuality: @(0.95)}];
54
+
55
+ if (weakSelf.cameraViewType == IPDFCameraViewTypeBlackAndWhite || weakSelf.isBorderDetectionEnabled)
56
+ {
57
+ - CIImage *enhancedImage = [CIImage imageWithData:imageData];
58
+ + // Use source image directly for better quality
59
+ + CIImage *enhancedImage = sourceImage;
60
+
61
+ if (weakSelf.cameraViewType == IPDFCameraViewTypeBlackAndWhite)
62
+ {
63
+ @@ -405,10 +424,17 @@
64
+ {
65
+ enhancedImage = [self correctPerspectiveForImage:enhancedImage withFeatures:rectangleFeature];
66
+
67
+ - UIGraphicsBeginImageContext(CGSizeMake(enhancedImage.extent.size.height, enhancedImage.extent.size.width));
68
+ - [[UIImage imageWithCIImage:enhancedImage scale:1.0 orientation:UIImageOrientationRight] drawInRect:CGRectMake(0,0, enhancedImage.extent.size.height, enhancedImage.extent.size.width)];
69
+ - UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
70
+ - UIImage *initialImage = [UIImage imageWithData:imageData];
71
+ - UIGraphicsEndImageContext();
72
+ + // Convert CIImage to UIImage with high quality using CIContext
73
+ + CIContext *ciContext = [CIContext contextWithOptions:@{kCIContextUseSoftwareRenderer: @(NO)}];
74
+ +
75
+ + // Apply rotation to match device orientation
76
+ + CGAffineTransform transform = CGAffineTransformMakeRotation(-M_PI_2);
77
+ + enhancedImage = [enhancedImage imageByApplyingTransform:transform];
78
+ +
79
+ + // Convert to CGImage first for better quality
80
+ + CGImageRef cgImage = [ciContext createCGImage:enhancedImage fromRect:enhancedImage.extent];
81
+ + UIImage *image = [UIImage imageWithCGImage:cgImage scale:1.0 orientation:UIImageOrientationUp];
82
+ + CGImageRelease(cgImage);
83
+ +
84
+ + UIImage *initialImage = [UIImage imageWithData:imageData];
85
+
86
+ [weakSelf hideGLKView:NO completion:nil];