Skip to content

Commit 0e5d5d4

Browse files
feat(Utility): add drawImage method (#5938)
* chore: bump version 9.6.1-beta02 Co-Authored-By: a0926019412 <[email protected]> * feat: 增加 drawImage 方法 --------- Co-authored-by: a0926019412 <[email protected]>
1 parent 9e542ab commit 0e5d5d4

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/BootstrapBlazor/BootstrapBlazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>9.6.1-beta01</Version>
4+
<Version>9.6.1-beta02</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

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)