@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 CHANGED
@@ -26,6 +26,7 @@ declare module '@wemap/camera' {
26
26
  maxWidth: number,
27
27
  maxHeight?: number
28
28
  ): HTMLCanvasElement;
29
+ static htmlImageToCanvas(image: HTMLImageElement): HTMLCanvasElement;
29
30
  }
30
31
 
31
32
  export type CameraOptions = {
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.0",
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": "d98a62dea33f5bcd93bc0eda133242da9fe441e3"
35
+ "gitHead": "f5c2315cc2406793433e8ff33a4152e0efe8f801"
36
36
  }
@@ -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
+ }