ccc-tnt-psd2ui/npm-packages/mac-v3.4.+/ag-psd/dist-es/initializeCanvas.js
2023-09-06 09:51:55 +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