1
0
mirror of https://gitee.com/onvia/ccc-tnt-psd2ui synced 2025-01-20 18:01:05 +00:00
2023-07-24 11:13:08 +08:00

22 lines
813 B
JavaScript

import { createCanvas } from 'canvas';
import { initializeCanvas } from './index';
import { decodeJpeg } from './jpeg';
function createCanvasFromData(data) {
var canvas = createCanvas(100, 100);
try {
var context_1 = canvas.getContext('2d');
var imageData = decodeJpeg(data, function (w, h) { return context_1.createImageData(w, h); });
canvas.width = imageData.width;
canvas.height = imageData.height;
context_1.putImageData(imageData, 0, 0);
}
catch (e) {
console.error('JPEG decompression error', e.message);
}
return canvas;
}
initializeCanvas(createCanvas, createCanvasFromData);
export function initialize() {
initializeCanvas(createCanvas, createCanvasFromData);
}
//# sourceMappingURL=initializeCanvas.js.map