當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript pngjs.PNG類代碼示例

本文整理匯總了TypeScript中pngjs.PNG的典型用法代碼示例。如果您正苦於以下問題:TypeScript PNG類的具體用法?TypeScript PNG怎麽用?TypeScript PNG使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PNG類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: doneReading

function doneReading() {
    if (++filesRead < 2) return;
    const diff = new PNG({width: img1.width, height: img1.height});

    pixelmatch(img1.data, img2.data, diff.data, img1.width, img1.height, {threshold: 0.1});

    diff.pack().pipe(fs.createWriteStream('diff.png'));
}
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:8,代碼來源:pixelmatch-tests.ts

示例2: Promise

		return new Promise(function (resolve, reject) {
			const png = new PNG();
			png.on('parsed', function () {
				resolve(png);
			});
			png.on('error', function (error) {
				reject(error);
			});

			load(image, png);
		});
開發者ID:devpaul,項目名稱:visual-regression,代碼行數:11,代碼來源:PngJsImageComparator.ts

示例3: export

  public static async export(path: string, out: string) {
    const buffer = await readFileP(path, { flag: 'r' }).catch(() => {
      console.log('File not found or could not be opened')
    })
    if (!buffer) {
      return
    }

    if (!existsSync(out)) {
      await mkdirP(out)
    }

    const arrayBuffer = toArrayBuffer(buffer)
    const wad = await Wad.parse(arrayBuffer)

    for (let i = 0; i < wad.entries.length; ++i) {
      const entry = wad.entries[i]
      if (entry.type !== 'texture') {
        continue
      }

      const msg = `Exporting: ${entry.name}`
      process.stdout.write(msg)

      const png = new PNG({
        width: entry.width,
        height: entry.height
      })

      const mipmap = entry.data
      for (let i = 0; i < mipmap.length; ++i) {
        png.data[i] = mipmap[i]
      }

      png.pack().pipe(createWriteStream(`${out}/${entry.name}.png`))

      const dots = []
      for (let j = 0; j < 30 - msg.length; ++j) {
        dots.push('.')
      }
      process.stdout.write(dots.join('') + 'DONE\n')
    }

    console.log(
      `\nSuccessfully exported all textures from "${resolve(
        process.cwd(),
        path
      )}"\n into "${resolve(process.cwd(), out)}" directory\n`
    )
  }
開發者ID:skyrim,項目名稱:hlviewer.js,代碼行數:50,代碼來源:index.ts

示例4: Error

png.bitblt(pngs[1]);
png.bitblt(pngs[1], 1);
png.bitblt(pngs[1], 1, 1);
png.bitblt(pngs[1], 1, 1, 1, 1, 1, 1);

png.on('metadata', metadata => {
	metadata.bpp === 1;
});
png.on('parsed', data => {
	data.byteLength === 1;
});
png.on('error', error => {
	error === new Error('testing');
});
png.on('foo', () => {});

png.pack().adjustGamma();

png.parse('foo').adjustGamma();
png.parse(Buffer.from('foo')).adjustGamma();
png.parse('foo', (error, data) => {
	error.stack;
	data.adjustGamma();
}).adjustGamma();

PNG.adjustGamma(png);

PNG.bitblt(png, pngs[1]);
PNG.bitblt(png, pngs[1], 1, 1, 1, 1, 1, 1);
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:29,代碼來源:pngjs-tests.ts

示例5: function

		mkdirp(dirname(filename), function (err) {
			if (err) {
				reject(err);
			}
			else {
				var stream = createWriteStream(filename);
				stream.on('finish', function () {
					resolve();
				});
				stream.on('error', function (error: Error) {
					reject(error);
				});
				png.pack().pipe(stream);
			}
		});
開發者ID:devpaul,項目名稱:visual-regression,代碼行數:15,代碼來源:saveDifferenceImage.ts


注:本文中的pngjs.PNG類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。