@capgo/camera-preview 8.14.0 → 8.14.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.
- package/dist/esm/web-capture-scaling.d.ts +11 -0
- package/dist/esm/web-capture-scaling.js +14 -0
- package/dist/esm/web-capture-scaling.js.map +1 -0
- package/dist/esm/web.js +3 -3
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +16 -3
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +16 -3
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapgoCameraPreviewPlugin/CameraController.swift +3 -1
- package/ios/Sources/CapgoCameraPreviewPlugin/CaptureLifecycleCoordination.swift +12 -13
- package/ios/Sources/CapgoCameraPreviewPlugin/Plugin.swift +6 -5
- package/ios/Tests/CameraPreviewPluginTests/CaptureLifecycleCoordinationTests.swift +46 -7
- package/package.json +2 -2
package/dist/plugin.js
CHANGED
|
@@ -39,6 +39,20 @@ var capacitorCapacitorCameraView = (function (exports, core) {
|
|
|
39
39
|
return !!success;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/** Source and destination rects for scaling a video frame into the capture canvas. */
|
|
43
|
+
function getWebCaptureImageDrawRects(videoWidth, videoHeight, captureWidth, captureHeight) {
|
|
44
|
+
return {
|
|
45
|
+
sx: 0,
|
|
46
|
+
sy: 0,
|
|
47
|
+
sWidth: videoWidth,
|
|
48
|
+
sHeight: videoHeight,
|
|
49
|
+
dx: 0,
|
|
50
|
+
dy: 0,
|
|
51
|
+
dWidth: captureWidth,
|
|
52
|
+
dHeight: captureHeight,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
42
56
|
const DEFAULT_VIDEO_ID = 'capgo_video';
|
|
43
57
|
class CameraPreviewWeb extends core.WebPlugin {
|
|
44
58
|
constructor() {
|
|
@@ -649,8 +663,6 @@ var capacitorCapacitorCameraView = (function (exports, core) {
|
|
|
649
663
|
// Calculate capture dimensions
|
|
650
664
|
let captureWidth = video.videoWidth;
|
|
651
665
|
let captureHeight = video.videoHeight;
|
|
652
|
-
const sourceX = 0;
|
|
653
|
-
const sourceY = 0;
|
|
654
666
|
// If width or height is specified, resize to fit within both maximums while maintaining aspect ratio
|
|
655
667
|
if (options.width || options.height) {
|
|
656
668
|
const originalAspectRatio = video.videoWidth / video.videoHeight;
|
|
@@ -689,7 +701,8 @@ var capacitorCapacitorCameraView = (function (exports, core) {
|
|
|
689
701
|
context === null || context === void 0 ? void 0 : context.translate(captureWidth, 0);
|
|
690
702
|
context === null || context === void 0 ? void 0 : context.scale(-1, 1);
|
|
691
703
|
}
|
|
692
|
-
|
|
704
|
+
const { sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight } = getWebCaptureImageDrawRects(video.videoWidth, video.videoHeight, captureWidth, captureHeight);
|
|
705
|
+
context === null || context === void 0 ? void 0 : context.drawImage(video, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
|
|
693
706
|
if (options.saveToGallery) ;
|
|
694
707
|
if (options.withExifLocation) ;
|
|
695
708
|
if ((options.format || 'jpeg') === 'jpeg') {
|