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)

54 lines 1.44 kB
import { IfdValue } from './ifd-value.js'; import { IfdValueType } from '../ifd-value-type.js'; import { LibError } from '../../error/lib-error.js'; export class IfdIfdValue extends IfdValue { get type() { return IfdValueType.ifd; } get length() { return 1; } constructor(value) { super(); this._offset = value; } static data(data) { const value = data.readUint32(); return new IfdIfdValue(value); } toInt(index = 0) { if (index !== 0) { throw new LibError('Ifd tags are required to have a single entry (the offset).'); } return this._offset; } toData() { return Uint8Array.from([ this._offset >> 24, this._offset >> 16, this._offset >> 8, this._offset, ]); } write(out) { out.writeUint32(this._offset); } setInt(v, index = 0) { if (index !== 0) { throw new LibError('Ifd tags are required to have a single entry (the offset).'); } this._offset = v; } equals(other) { return (other instanceof IfdIfdValue && this.length === other.length && this._offset === other._offset); } clone() { return new IfdIfdValue(this._offset); } toString() { return this._offset.toString(); } } //# sourceMappingURL=ifd-ifd-value.js.map