How to use the pureimage.decodePNGFromStream function in pureimage

To help you get started, we’ve selected a few pureimage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ngageoint / geopackage-js / test / fixtures / testSetup.js View on Github external
module.exports.diffImagesWithDimensions = function(actualTile, expectedTilePath, width, height, callback) {
  if (typeof(process) !== 'undefined' && process.version) {

    var chunkStream = new Duplex();
    chunkStream.push(actualTile);
    chunkStream.push(null);
    pureimage.decodePNGFromStream(chunkStream).then(function(actualImage) {
      pureimage.decodePNGFromStream(fs.createReadStream(expectedTilePath)).then(function(expectedImage) {
        var same = true;
        for (var x = 0; x < actualImage.width && same; x++) {
          for (var y = 0; y < actualImage.height && same; y++) {
            var actualRGBA = actualImage.getPixelRGBA(x,y);
            var expectedRGBA = expectedImage.getPixelRGBA(x,y);
            same = actualRGBA === expectedRGBA;
          }
        }
        callback(null, same);
      });
    });
  } else {
    if (actualTile instanceof Uint8Array) {
      var binary = '';
      var bytes = actualTile;
github ngageoint / geopackage-js / test / fixtures / testSetup.js View on Github external
pureimage.decodePNGFromStream(chunkStream).then(function(actualImage) {
      pureimage.decodePNGFromStream(fs.createReadStream(expectedTilePath)).then(function(expectedImage) {
        var same = true;
        for (var x = 0; x < actualImage.width && same; x++) {
          for (var y = 0; y < actualImage.height && same; y++) {
            var actualRGBA = actualImage.getPixelRGBA(x,y);
            var expectedRGBA = expectedImage.getPixelRGBA(x,y);
            same = actualRGBA === expectedRGBA;
          }
        }
        callback(null, same);
      });
    });
  } else {
github vladimiry / ElectronMail / src / electron-main / api / endpoints-builders / tray-icon / lib.ts View on Github external
export async function trayIconBundleFromPath(trayIconPath: string): Promise<ImageBundle> {
    const bitmap = await decodePNGFromStream(createReadStream(trayIconPath));

    return {
        bitmap,
        native: await bitmapToNativeImage(bitmap),
    };
}