How to use fast-png - 5 common examples

To help you get started, we’ve selected a few fast-png 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 danakt / web-hlmv / lib / __tests__ / textureRenderer.ts View on Github external
test('should build valid skin texture', () => {
    const texture = leetModelData.textures[0]
    const buildedSkin: Uint8Array = png.encode({
      width:  texture.width,
      height: texture.height,
      data:   buildTexture(leetBuffer, texture)
    })

    expect(Buffer.from(buildedSkin)).toMatchImageSnapshot()
  })
github image-js / image-js / src / image / core / export.js View on Github external
width: image.width,
    height: image.height,
    components: image.components,
    alpha: image.alpha,
    bitDepth: image.bitDepth,
    data: image.data
  };

  if (data.bitDepth === 1 || data.bitDepth === 32) {
    data.bitDepth = 8;
    data.components = 3;
    data.alpha = 1;
    data.data = image.getRGBAData();
  }

  return realEncodePng(data, options);
}
github image-js / image-js / packages / image-js / src / save / encodePng.ts View on Github external
export function encodePng(
  image: Image,
  options?: IPNGEncoderOptions
): Uint8Array {
  return encode(image, options);
}
github image-js / image-js / src / image / core / load.js View on Github external
function loadPNG(data) {
  const png = decodePng(data);

  let components;
  let alpha = 0;
  switch (png.colourType) {
    case 0:
      components = 1;
      break;
    case 2:
      components = 3;
      break;
    case 3:
      return loadPNGFromPalette(png);
    case 4:
      components = 1;
      alpha = 1;
      break;
github image-js / image-js / packages / image-js / src / load / decodePng.ts View on Github external
export function decodePng(buffer: Uint8Array): Image {
  const png = decode(buffer);

  let kind: ImageKind;
  const depth: ColorDepth =
    png.depth === 16 ? ColorDepth.UINT16 : ColorDepth.UINT8;

  if (png.palette) {
    return loadPalettePNG(png);
  }

  switch (png.channels) {
    case 1:
      kind = ImageKind.GREY;
      break;
    case 2:
      kind = ImageKind.GREYA;
      break;

fast-png

PNG image decoder and encoder written entirely in JavaScript

MIT
Latest version published 10 months ago

Package Health Score

69 / 100
Full package analysis

Popular fast-png functions