Skip to content

Commit 81bacf8

Browse files
committed
feat: 增加 drawImage 方法
1 parent f1cd912 commit 81bacf8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/BootstrapBlazor/wwwroot/modules/utility.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,16 @@ export function setMemorialMode(memorial) {
876876
}
877877
}
878878

879+
export function drawImage(canvas, image, offsetWidth, offsetHeight) {
880+
canvas.width = offsetWidth * devicePixelRatio;
881+
canvas.height = offsetHeight * devicePixelRatio;
882+
canvas.style.width = `${offsetWidth}px`;
883+
canvas.style.height = `${offsetHeight}px`;
884+
const context = canvas.getContext('2d');
885+
context.scale(devicePixelRatio, devicePixelRatio);
886+
context.drawImage(image, 0, 0, offsetWidth, offsetHeight);
887+
}
888+
879889
export {
880890
autoAdd,
881891
autoRemove,

0 commit comments

Comments
 (0)