@wemap/camera 10.0.0-alpha.0 → 10.0.0-alpha.7
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/index.d.ts +1 -0
- package/package.json +2 -2
- package/src/CameraUtils.js +13 -0
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"directory": "packages/camera"
|
|
13
13
|
},
|
|
14
14
|
"name": "@wemap/camera",
|
|
15
|
-
"version": "10.0.0-alpha.
|
|
15
|
+
"version": "10.0.0-alpha.7",
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
18
18
|
},
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"@types/events": "^3.0.0"
|
|
33
33
|
},
|
|
34
34
|
"type": "module",
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "f5c2315cc2406793433e8ff33a4152e0efe8f801"
|
|
36
36
|
}
|
package/src/CameraUtils.js
CHANGED
|
@@ -158,3 +158,16 @@ export function reduceImageSize(imageCanvas, maxWidth, maxHeight = null) {
|
|
|
158
158
|
return newCanvas;
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
/**
|
|
162
|
+
* @param {HTMLImageElement} image
|
|
163
|
+
* @returns {HTMLCanvasElement}
|
|
164
|
+
*/
|
|
165
|
+
export function htmlImageToCanvas(image) {
|
|
166
|
+
const canvas = document.createElement('canvas');
|
|
167
|
+
canvas.width = image.width;
|
|
168
|
+
canvas.height = image.height;
|
|
169
|
+
const context = canvas.getContext('2d');
|
|
170
|
+
context.scale(canvas.width / image.width, canvas.height / image.height);
|
|
171
|
+
context.drawImage(image, 0, 0);
|
|
172
|
+
return canvas;
|
|
173
|
+
}
|