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)

369 lines (368 loc) 13.1 kB
/** @format */ import { InputBuffer } from '../../common/input-buffer.js'; import { VP8LImageTransformType } from './vp8l-image-transform-type.js'; /** * Class representing a VP8L Transform. */ export declare class VP8LTransform { /** * Type of the transform. */ private _type; /** * Gets the type of the transform. */ get type(): VP8LImageTransformType; /** * Sets the type of the transform. */ set type(v: VP8LImageTransformType); /** * Width of the transform. */ private _xsize; /** * Gets the width of the transform. */ get xsize(): number; /** * Sets the width of the transform. */ set xsize(v: number); /** * Height of the transform. */ private _ysize; /** * Gets the height of the transform. */ get ysize(): number; /** * Sets the height of the transform. */ set ysize(v: number); /** * Data of the transform. */ private _data?; /** * Gets the data of the transform. */ get data(): Uint32Array | undefined; /** * Sets the data of the transform. */ set data(v: Uint32Array | undefined); /** * Bits of the transform. */ private _bits; /** * Gets the bits of the transform. */ get bits(): number; /** * Sets the bits of the transform. */ set bits(v: number); /** * Applies the inverse transform. * @param {number} rowStart - The starting row. * @param {number} rowEnd - The ending row. * @param {Uint32Array} inData - Input data array. * @param {number} rowsIn - Number of input rows. * @param {Uint32Array} outData - Output data array. * @param {number} rowsOut - Number of output rows. */ inverseTransform(rowStart: number, rowEnd: number, inData: Uint32Array, rowsIn: number, outData: Uint32Array, rowsOut: number): void; /** * Applies the color index inverse transform for alpha channel. * @param {number} yStart - The starting row. * @param {number} yEnd - The ending row. * @param {InputBuffer<Uint8Array>} src - Source input buffer. * @param {InputBuffer<Uint8Array>} dst - Destination input buffer. */ colorIndexInverseTransformAlpha(yStart: number, yEnd: number, src: InputBuffer<Uint8Array>, dst: InputBuffer<Uint8Array>): void; /** * Applies the color index inverse transform. * @param {number} yStart - The starting row. * @param {number} yEnd - The ending row. * @param {Uint32Array} inData - Input data array. * @param {number} src - Source index. * @param {Uint32Array} outData - Output data array. * @param {number} dst - Destination index. */ colorIndexInverseTransform(yStart: number, yEnd: number, inData: Uint32Array, src: number, outData: Uint32Array, dst: number): void; /** * Applies the color space inverse transform. * @param {number} yStart - The starting row. * @param {number} yEnd - The ending row. * @param {Uint32Array} outData - Output data array. * @param {number} data - Data index. */ colorSpaceInverseTransform(yStart: number, yEnd: number, outData: Uint32Array, data: number): void; /** * Applies the predictor inverse transform. * @param {number} yStart - The starting row. * @param {number} yEnd - The ending row. * @param {Uint32Array} outData - Output data array. * @param {number} data - Data index. */ predictorInverseTransform(yStart: number, yEnd: number, outData: Uint32Array, data: number): void; /** * Adds green to blue and red channels. * @param {Uint32Array} pixels - The pixel data array. * @param {number} data - Data index. * @param {number} dataEnd - End index of the data. */ addGreenToBlueAndRed(pixels: Uint32Array, data: number, dataEnd: number): void; /** * Gets the ARGB index. * @param {number} idx - The index value. * @returns {number} The ARGB index. */ private static getARGBIndex; /** * Gets the alpha index. * @param {number} idx - The index value. * @returns {number} The alpha index. */ private static getAlphaIndex; /** * Gets the ARGB value. * @param {number} val - The value. * @returns {number} The ARGB value. */ private static getARGBValue; /** * Gets the alpha value. * @param {number} val - The value. * @returns {number} The alpha value. */ private static getAlphaValue; /** * In-place sum of each component with mod 256. * @param {Uint32Array} pixels - The pixel data array. * @param {number} a - Index a. * @param {number} b - Index b. */ private static addPixelsEq; /** * Averages two values. * @param {number} a0 - Value 0. * @param {number} a1 - Value 1. * @returns {number} The average value. */ private static average2; /** * Averages three values. * @param {number} a0 - Value 0. * @param {number} a1 - Value 1. * @param {number} a2 - Value 2. * @returns {number} The average value. */ private static average3; /** * Averages four values. * @param {number} a0 - Value 0. * @param {number} a1 - Value 1. * @param {number} a2 - Value 2. * @param {number} a3 - Value 3. * @returns {number} The average value. */ private static average4; /** * Clips the value to 0 or 255. * @param {number} a - The value. * @returns {number} The clipped value. */ private static clip255; /** * Adds and subtracts components with full range. * @param {number} a - Value a. * @param {number} b - Value b. * @param {number} c - Value c. * @returns {number} The result. */ private static addSubtractComponentFull; /** * Clamped add and subtract with full range. * @param {number} c0 - Value 0. * @param {number} c1 - Value 1. * @param {number} c2 - Value 2. * @returns {number} The result. */ private static clampedAddSubtractFull; /** * Adds the given number `a` to half the difference between `a` and `b`, * then clips the result to a maximum value of 255. * * @param {number} a - The first number. * @param {number} b - The second number. * @returns {number} The result of the operation, clipped to a maximum of 255. */ private static addSubtractComponentHalf; /** * Performs a clamped addition and subtraction operation on the half components of the given numbers. * * This function calculates the average of the first two input numbers, then performs an add/subtract * operation on each color component (alpha, red, green, blue) with the third input number. * * @param {number} c0 - The first input number. * @param {number} c1 - The second input number. * @param {number} c2 - The third input number. * @returns {number} The result of the clamped add/subtract operation on the half components. */ private static clampedAddSubtractHalf; /** * Subtracts the third parameter from the first two parameters, * calculates the absolute values of the results, and returns * the difference between these absolute values. * * @param {number} a - The first number. * @param {number} b - The second number. * @param {number} c - The third number to be subtracted from the first two numbers. * @returns {number} The difference between the absolute values of (b - c) and (a - c). */ private static sub3; /** * Selects between two numbers based on a comparison with a third number. * * @param {number} a - The first number to compare. * @param {number} b - The second number to compare. * @param {number} c - The number to compare against. * @returns {number} The selected number, either `a` or `b`. */ private static select; /** * A static method that predicts a value based on the given pixel data. * * @param {Uint32Array} _pixels - An array of 32-bit unsigned integers representing pixel data. * @param {number} _left - The left coordinate for the prediction. * @param {number} _top - The top coordinate for the prediction. * @returns {number} A constant value representing a black ARGB color. */ private static predictor0; /** * A predictor function that returns the value of the left pixel. * * @param {Uint32Array} _pixels - The array of pixel data. * @param {number} left - The value of the left pixel. * @param {number} _top - The value of the top pixel (unused). * @returns {number} The value of the left pixel. */ private static predictor1; /** * Predicts the value using the second predictor method. * * @param {Uint32Array} pixels - The array of pixel values. * @param {number} _left - The left pixel value (unused). * @param {number} top - The top pixel index. * @returns {number} The predicted pixel value. */ private static predictor2; /** * Predicts the value using the third predictor method. * * @param {Uint32Array} pixels - The array of pixel values. * @param {number} _left - The left pixel value (unused). * @param {number} top - The top pixel index. * @returns {number} The predicted pixel value. */ private static predictor3; /** * Predicts the value using the fourth predictor method. * * @param {Uint32Array} pixels - The array of pixel values. * @param {number} _left - The left pixel value (unused). * @param {number} top - The top pixel index. * @returns {number} The predicted pixel value. */ private static predictor4; /** * Predicts the value using the fifth predictor method. * * @param {Uint32Array} pixels - The array of pixel values. * @param {number} left - The left pixel value. * @param {number} top - The top pixel index. * @returns {number} The predicted pixel value. */ private static predictor5; /** * Predicts the value using the sixth predictor method. * * @param {Uint32Array} pixels - The array of pixel values. * @param {number} left - The left pixel value. * @param {number} top - The top pixel index. * @returns {number} The predicted pixel value. */ private static predictor6; /** * Predicts the value using the seventh predictor method. * * @param {Uint32Array} pixels - The array of pixel values. * @param {number} left - The left pixel value. * @param {number} top - The top pixel index. * @returns {number} The predicted pixel value. */ private static predictor7; /** * Predicts the value using the eighth predictor method. * * @param {Uint32Array} pixels - The array of pixel values. * @param {number} _left - The left pixel value (unused). * @param {number} top - The top pixel index. * @returns {number} The predicted pixel value. */ private static predictor8; /** * Predicts the value using the ninth predictor method. * * @param {Uint32Array} pixels - The array of pixel values. * @param {number} _left - The left pixel value (unused). * @param {number} top - The top pixel index. * @returns {number} The predicted pixel value. */ private static predictor9; /** * Predicts the value using the tenth predictor method. * * @param {Uint32Array} pixels - The array of pixel values. * @param {number} left - The left pixel value. * @param {number} top - The top pixel index. * @returns {number} The predicted pixel value. */ private static predictor10; /** * Predicts the value using the eleventh predictor method. * * @param {Uint32Array} pixels - The array of pixel values. * @param {number} left - The left pixel value. * @param {number} top - The top pixel index. * @returns {number} The predicted pixel value. */ private static predictor11; /** * Predicts the value using the twelfth predictor method. * * @param {Uint32Array} pixels - The array of pixel values. * @param {number} left - The left pixel value. * @param {number} top - The top pixel index. * @returns {number} The predicted pixel value. */ private static predictor12; /** * Predicts the value using the thirteenth predictor method. * * @param {Uint32Array} pixels - The array of pixel values. * @param {number} left - The left pixel value. * @param {number} top - The top pixel index. * @returns {number} The predicted pixel value. */ private static predictor13; /** * Array of predictor functions. * Each predictor function is referenced by its index. */ private static readonly predictors; }