修复pma 皮肤渲染
This commit is contained in:
1 parent
02358b8d4c
commit
11b1c95d98
6 files changed
+105
-13
No files matched your search
@@ -35,8 +35,13 @@ function imageForCanvas(image, context, premultipliedAlpha) {
|
||||
try {
|
||||
const ownerDocument = context.canvas && context.canvas.ownerDocument;
|
||||
const doc = ownerDocument || (typeof document !== 'undefined' ? document : null);
|
||||
if (!doc || !image.width || !image.height) return image;
|
||||
const canvas = doc.createElement('canvas');
|
||||
if (!image.width || !image.height) return image;
|
||||
let canvas;
|
||||
if (doc) canvas = doc.createElement('canvas');
|
||||
else {
|
||||
try { canvas = require('@napi-rs/canvas').createCanvas(image.width, image.height); }
|
||||
catch (e) { return image; }
|
||||
}
|
||||
canvas.width = image.width;
|
||||
canvas.height = image.height;
|
||||
const ctx = canvas.getContext('2d', { willReadFrequently: true });
|
||||
|
||||
Reference in new issue
Block a user