How to use the @jimp/utils.scan function in @jimp/utils

To help you get started, we’ve selected a few @jimp/utils 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 oliver-moran / jimp / packages / core / src / index.js View on Github external
jimpEvChange('scan', function(x, y, w, h, f, cb) {
  if (typeof x !== 'number' || typeof y !== 'number') {
    return throwError.call(this, 'x and y must be numbers', cb);
  }

  if (typeof w !== 'number' || typeof h !== 'number') {
    return throwError.call(this, 'w and h must be numbers', cb);
  }

  if (typeof f !== 'function') {
    return throwError.call(this, 'f must be a function', cb);
  }

  const result = scan(this, x, y, w, h, f);

  if (isNodePattern(cb)) {
    cb.call(this, null, result);
  }

  return result;
});
github oliver-moran / jimp / packages / type-bmp / src / index.js View on Github external
function toAGBR(image) {
  return scan(image, 0, 0, image.bitmap.width, image.bitmap.height, function(
    x,
    y,
    index
  ) {
    const red = this.bitmap.data[index + 0];
    const green = this.bitmap.data[index + 1];
    const blue = this.bitmap.data[index + 2];
    const alpha = this.bitmap.data[index + 3];

    this.bitmap.data[index + 0] = alpha;
    this.bitmap.data[index + 1] = blue;
    this.bitmap.data[index + 2] = green;
    this.bitmap.data[index + 3] = red;
  }).bitmap;
}
github oliver-moran / jimp / packages / type-bmp / src / index.js View on Github external
function fromAGBR(bitmap) {
  return scan({ bitmap }, 0, 0, bitmap.width, bitmap.height, function(
    x,
    y,
    index
  ) {
    const alpha = this.bitmap.data[index + 0];
    const blue = this.bitmap.data[index + 1];
    const green = this.bitmap.data[index + 2];
    const red = this.bitmap.data[index + 3];

    this.bitmap.data[index + 0] = red;
    this.bitmap.data[index + 1] = green;
    this.bitmap.data[index + 2] = blue;
    this.bitmap.data[index + 3] = bitmap.is_with_alpha ? alpha : 0xff;
  }).bitmap;
}

@jimp/utils

MIT
Latest version published 8 days ago

Package Health Score

92 / 100
Full package analysis