@carviz/capacitor-camera-preview 7.0.0 → 7.0.2
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.
|
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.source = { :git => 'https://github.com/GetCarviz/capacitor-camera-preview.git', :tag => s.version.to_s }
|
|
13
13
|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
-
s.ios.deployment_target = '
|
|
14
|
+
s.ios.deployment_target = '14.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
16
|
s.swift_version = '5.1'
|
|
17
17
|
end
|
|
@@ -152,7 +152,7 @@ class CameraController: NSObject {
|
|
|
152
152
|
// Note that zoomFactor 2 "equals" the regular 1x zoom factor of the native iphone camera app
|
|
153
153
|
// 0.5x however equal a videoZoomFactor of 1. We do not want to use ultra wide angle by default
|
|
154
154
|
// the default videoZoomFactor to 2 in case the current camera device type is .builtInTripleCamera
|
|
155
|
-
cameraDevice.videoZoomFactor = 2
|
|
155
|
+
cameraDevice.videoZoomFactor = 1.2
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
|
|
@@ -391,17 +391,59 @@ class CameraController: NSObject {
|
|
|
391
391
|
}
|
|
392
392
|
|
|
393
393
|
extension UIImage {
|
|
394
|
-
func fixedOrientation() -> UIImage {
|
|
395
|
-
|
|
396
|
-
|
|
394
|
+
func fixedOrientation() -> UIImage? {
|
|
395
|
+
guard imageOrientation != UIImage.Orientation.up else {
|
|
396
|
+
// This is default orientation, don't need to do anything
|
|
397
|
+
return self.copy() as? UIImage
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
guard let cgImage = self.cgImage else {
|
|
401
|
+
// CGImage is not available
|
|
402
|
+
return nil
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
guard let colorSpace = cgImage.colorSpace, let ctx = CGContext(data: nil, width: Int(size.width), height: Int(size.height), bitsPerComponent: cgImage.bitsPerComponent, bytesPerRow: 0, space: colorSpace, bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue) else {
|
|
406
|
+
// Not able to create CGContext
|
|
407
|
+
return nil
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
var transform: CGAffineTransform = CGAffineTransform.identity
|
|
411
|
+
|
|
412
|
+
switch imageOrientation {
|
|
413
|
+
case .down, .downMirrored:
|
|
414
|
+
transform = transform.translatedBy(x: size.width, y: size.height)
|
|
415
|
+
transform = transform.rotated(by: CGFloat.pi)
|
|
416
|
+
print("down")
|
|
417
|
+
break
|
|
418
|
+
case .left, .leftMirrored:
|
|
419
|
+
transform = transform.translatedBy(x: size.width, y: 0)
|
|
420
|
+
transform = transform.rotated(by: CGFloat.pi / 2.0)
|
|
421
|
+
print("left")
|
|
422
|
+
break
|
|
423
|
+
case .right, .rightMirrored:
|
|
424
|
+
transform = transform.translatedBy(x: 0, y: size.height)
|
|
425
|
+
transform = transform.rotated(by: CGFloat.pi / -2.0)
|
|
426
|
+
print("right")
|
|
427
|
+
break
|
|
428
|
+
case .up, .upMirrored:
|
|
429
|
+
break
|
|
430
|
+
@unknown default:
|
|
431
|
+
break
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
ctx.concatenate(transform)
|
|
435
|
+
|
|
436
|
+
switch imageOrientation {
|
|
437
|
+
case .left, .leftMirrored, .right, .rightMirrored:
|
|
438
|
+
ctx.draw(self.cgImage!, in: CGRect(x: 0, y: 0, width: size.height, height: size.width))
|
|
439
|
+
default:
|
|
440
|
+
ctx.draw(self.cgImage!, in: CGRect(x: 0, y: 0, width: size.width, height: size.height))
|
|
441
|
+
break
|
|
397
442
|
}
|
|
398
443
|
|
|
399
|
-
|
|
400
|
-
draw(in: CGRect(origin: .zero, size: size))
|
|
401
|
-
let normalizedImage = UIGraphicsGetImageFromCurrentImageContext()!
|
|
402
|
-
UIGraphicsEndImageContext()
|
|
444
|
+
guard let newCGImage = ctx.makeImage() else { return nil }
|
|
403
445
|
|
|
404
|
-
return
|
|
446
|
+
return UIImage.init(cgImage: newCGImage, scale: 1, orientation: .up)
|
|
405
447
|
}
|
|
406
448
|
}
|
|
407
449
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carviz/capacitor-camera-preview",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.2",
|
|
4
4
|
"description": "Fork of the capacitor-community/camera-preview plugin focusing on high resolution photos without bloating up the code.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/plugin.cjs.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"prepublishOnly": "npm run build",
|
|
24
24
|
"prepare": "husky && npm run build"
|
|
25
25
|
},
|
|
26
|
-
"author": "
|
|
26
|
+
"author": "Evan Barberousse",
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@capacitor/android": "^7.0.1",
|
package/ios/Plugin/UIImage.swift
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
extension UIImage {
|
|
2
|
-
func fixedOrientation() -> UIImage? {
|
|
3
|
-
guard imageOrientation != UIImage.Orientation.up else {
|
|
4
|
-
// This is default orientation, don't need to do anything
|
|
5
|
-
return self.copy() as? UIImage
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
guard let cgImage = self.cgImage else {
|
|
9
|
-
// CGImage is not available
|
|
10
|
-
return nil
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
guard let colorSpace = cgImage.colorSpace, let ctx = CGContext(data: nil, width: Int(size.width), height: Int(size.height), bitsPerComponent: cgImage.bitsPerComponent, bytesPerRow: 0, space: colorSpace, bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue) else {
|
|
14
|
-
// Not able to create CGContext
|
|
15
|
-
return nil
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
var transform: CGAffineTransform = CGAffineTransform.identity
|
|
19
|
-
|
|
20
|
-
switch imageOrientation {
|
|
21
|
-
case .down, .downMirrored:
|
|
22
|
-
transform = transform.translatedBy(x: size.width, y: size.height)
|
|
23
|
-
transform = transform.rotated(by: CGFloat.pi)
|
|
24
|
-
print("down")
|
|
25
|
-
break
|
|
26
|
-
case .left, .leftMirrored:
|
|
27
|
-
transform = transform.translatedBy(x: size.width, y: 0)
|
|
28
|
-
transform = transform.rotated(by: CGFloat.pi / 2.0)
|
|
29
|
-
print("left")
|
|
30
|
-
break
|
|
31
|
-
case .right, .rightMirrored:
|
|
32
|
-
transform = transform.translatedBy(x: 0, y: size.height)
|
|
33
|
-
transform = transform.rotated(by: CGFloat.pi / -2.0)
|
|
34
|
-
print("right")
|
|
35
|
-
break
|
|
36
|
-
case .up, .upMirrored:
|
|
37
|
-
break
|
|
38
|
-
@unknown default:
|
|
39
|
-
break
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
ctx.concatenate(transform)
|
|
43
|
-
|
|
44
|
-
switch imageOrientation {
|
|
45
|
-
case .left, .leftMirrored, .right, .rightMirrored:
|
|
46
|
-
ctx.draw(self.cgImage!, in: CGRect(x: 0, y: 0, width: size.height, height: size.width))
|
|
47
|
-
default:
|
|
48
|
-
ctx.draw(self.cgImage!, in: CGRect(x: 0, y: 0, width: size.width, height: size.height))
|
|
49
|
-
break
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
guard let newCGImage = ctx.makeImage() else { return nil }
|
|
53
|
-
|
|
54
|
-
return UIImage.init(cgImage: newCGImage, scale: 1, orientation: .up)
|
|
55
|
-
}
|
|
56
|
-
}
|