UNPKG

image-in-browser

Version:

Package for encoding / decoding images, transforming images, applying filters, drawing primitives on images on the client side (no need for server Node.js)

56 lines 1.63 kB
import { ArrayUtils } from '../../common/array-utils.js'; import { IcoInfoImage } from './ico-info-image.js'; import { IcoType, IcoTypeLength } from './ico-type.js'; export class IcoInfo { get width() { return this._width; } get height() { return this._height; } get type() { return this._type; } get numFrames() { return this._numFrames; } get backgroundColor() { return this._backgroundColor; } get images() { return this._images; } constructor(type, numFrames, images) { this._width = 0; this._height = 0; this._backgroundColor = undefined; this._type = type; this._numFrames = numFrames; this._images = images; } static read(input) { if (input.readUint16() !== 0) { return undefined; } const t = input.readUint16(); if (t >= IcoTypeLength) { return undefined; } const type = t; if (type === IcoType.cur) { return undefined; } const imageCount = input.readUint16(); const images = ArrayUtils.generate(imageCount, (_) => new IcoInfoImage({ width: input.read(), height: input.read(), colorPalette: input.read(), colorPlanes: (input.skip(1), input).readUint16(), bitsPerPixel: input.readUint16(), bytesSize: input.readUint32(), bytesOffset: input.readUint32(), })); return new IcoInfo(type, imageCount, images); } } //# sourceMappingURL=ico-info.js.map