mirror of
https://gitee.com/onvia/ccc-tnt-psd2ui
synced 2024-12-29 13:07:43 +00:00
28 lines
3.2 KiB
JavaScript
28 lines
3.2 KiB
JavaScript
|
"use strict";
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
exports.initialize = void 0;
|
||
|
var canvas_1 = require("canvas");
|
||
|
var index_1 = require("./index");
|
||
|
var jpeg_1 = require("./jpeg");
|
||
|
function createCanvasFromData(data) {
|
||
|
var canvas = (0, canvas_1.createCanvas)(100, 100);
|
||
|
try {
|
||
|
var context_1 = canvas.getContext('2d');
|
||
|
var imageData = (0, jpeg_1.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;
|
||
|
}
|
||
|
(0, index_1.initializeCanvas)(canvas_1.createCanvas, createCanvasFromData);
|
||
|
function initialize() {
|
||
|
(0, index_1.initializeCanvas)(canvas_1.createCanvas, createCanvasFromData);
|
||
|
}
|
||
|
exports.initialize = initialize;
|
||
|
|
||
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluaXRpYWxpemVDYW52YXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsaUNBQXNDO0FBQ3RDLGlDQUEyQztBQUMzQywrQkFBb0M7QUFFcEMsU0FBUyxvQkFBb0IsQ0FBQyxJQUFnQjtJQUM3QyxJQUFNLE1BQU0sR0FBRyxJQUFBLHFCQUFZLEVBQUMsR0FBRyxFQUFFLEdBQUcsQ0FBQyxDQUFDO0lBRXRDLElBQUk7UUFDSCxJQUFNLFNBQU8sR0FBRyxNQUFNLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBRSxDQUFDO1FBQ3pDLElBQU0sU0FBUy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