Skip to content

Commit 63d1f6c

Browse files
committed
feat: 精简代码
1 parent 1cf7e5a commit 63d1f6c

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

  • src/BootstrapBlazor/wwwroot/modules

src/BootstrapBlazor/wwwroot/modules/media.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
export async function enumerateDevices() {
1+
import { drawImage } from "./utility.js"
2+
3+
window.BootstrapBlazor = window.BootstrapBlazor || {};
4+
window.BootstrapBlazor[name] = window.BootstrapBlazor[name] || {
5+
6+
7+
export async function enumerateDevices() {
28
let ret = null;
39
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia || !navigator.mediaDevices.enumerateDevices) {
410
console.log("enumerateDevices() not supported.");
@@ -60,13 +66,3 @@ export async function capture(videoSelector) {
6066
}
6167
}
6268
}
63-
64-
const drawImage = (canvas, image, offsetWidth, offsetHeight) => {
65-
canvas.width = offsetWidth * devicePixelRatio;
66-
canvas.height = offsetHeight * devicePixelRatio;
67-
canvas.style.width = `${offsetWidth}px`;
68-
canvas.style.height = `${offsetHeight}px`;
69-
const context = canvas.getContext('2d')
70-
//context.scale(devicePixelRatio, devicePixelRatio)
71-
context.drawImage(image, 0, 0, offsetWidth, offsetHeight);
72-
}

0 commit comments

Comments
 (0)