本文整理匯總了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));
}