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)

49 lines 1.46 kB
import { IfdValue } from './ifd-value.js'; import { IfdValueType } from '../ifd-value-type.js'; import { ArrayUtils } from '../../common/array-utils.js'; export class IfdSByteValue extends IfdValue { get type() { return IfdValueType.sByte; } get length() { return this._value.length; } constructor(value) { super(); if (typeof value === 'number') { this._value = new Int8Array(1); this._value[0] = value; } else { this._value = Int8Array.from(value); } } static data(data, offset, length) { const array = new Int8Array(new Int8Array(data.toUint8Array(offset, length).buffer)); return new IfdSByteValue(array); } toInt(index = 0) { return this._value[index]; } toData() { return new Uint8Array(this._value.buffer); } write(out) { out.writeBytes(new Uint8Array(this._value.buffer)); } setInt(v, index = 0) { this._value[index] = v; } equals(other) { return (other instanceof IfdSByteValue && this.length === other.length && ArrayUtils.equals(this._value, other._value)); } clone() { return new IfdSByteValue(this._value); } toString() { return `${this.constructor.name} (${this._value.length === 1 ? `${this._value[0]}` : `${this._value}`})`; } } //# sourceMappingURL=ifd-sbyte-value.js.map