本文整理汇总了TypeScript中pngjs.PNG.sync类的典型用法代码示例。如果您正苦于以下问题:TypeScript PNG.sync类的具体用法?TypeScript PNG.sync怎么用?TypeScript PNG.sync使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PNG.sync类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: savePngDiff
export async function savePngDiff(file: string, png: PNG): Promise<string> {
const data = PNG.sync.write(png);
const outputDir = path.resolve(process.cwd(), './build/test-output/integration');
const diffPath = path.resolve(outputDir, file);
await fs.mkdir(outputDir, { recursive: true });
await fs.writeFile(diffPath, data);
return diffPath;
}
示例2: _loadImage
private _loadImage(image: ImageReference): Promise<{
png: PNG,
metadata: ImageMetadata
}> {
const loadPromise = (typeof image === 'string') ?
this._loadPng(image) : Promise.resolve(PNG.sync.read(image));
return loadPromise
.then(function (png: PNG) {
return {
png,
metadata: {
height: png.height,
width: png.width
}
};
});
}
示例3: decodePng
function decodePng(path) {
const buffer = fs.readFileSync(path);
return PNG.sync.read(buffer);
};
示例4: readPng
export async function readPng(file: string): Promise<PNG> {
const data = await fs.readFile(path.resolve(process.cwd(), file));
return PNG.sync.read(data);
}
示例5: writePng
export async function writePng(file: string, frame: Uint8Array, decoder: Decoder): Promise<void> {
const png = frameToPng(frame, decoder);
const data = PNG.sync.write(png);
await fs.writeFile(path.resolve(process.cwd(), file), data);
}
示例6: write_png
function write_png(file, image) {
const img = new PNG({width: image.width, height: image.height});
img.data = image.data;
fs.writeFileSync(file, PNG.sync.write(img));
}