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)
112 lines (111 loc) • 4.18 kB
TypeScript
/** @format */
import { MemoryImage } from '../image/image.js';
import { Decoder, DecoderDecodeOptions } from './decoder.js';
import { ImageFormat } from './image-format.js';
import { PvrAppleInfo } from './pvr/pvr-apple-info.js';
import { Pvr2Info } from './pvr/pvr2-info.js';
import { Pvr3Info } from './pvr/pvr3-info.js';
/**
* Ported from Jeffrey Lim's PVRTC encoder/decoder,
* https://bitbucket.org/jthlim/pvrtccompressor
*/
export declare class PvrDecoder implements Decoder {
/**
* Size of the PVR header.
*/
private static readonly pvrHeaderSize;
/**
* The data to be decoded.
*/
private _data;
/**
* Information about the decoded data.
*/
private _info;
/**
* Gets the image format.
*/
get format(): ImageFormat;
/**
* Gets the number of frames.
*/
get numFrames(): number;
/**
* Decodes the PVR3 header.
* @param {Uint8Array} bytes - The byte array containing the header.
* @returns {Pvr3Info | undefined} The decoded PVR3 information or undefined if invalid.
*/
private decodePvr3Header;
/**
* Decodes the PVR2 header.
* @param {Uint8Array} bytes - The byte array containing the header.
* @returns {Pvr2Info | undefined} The decoded PVR2 information or undefined if invalid.
*/
private decodePvr2Header;
/**
* Decodes the Apple PVRTC header.
* @param {Uint8Array} bytes - The byte array containing the header.
* @returns {PvrAppleInfo | undefined} The decoded Apple PVRTC information or undefined if invalid.
*/
private decodeApplePvrtcHeader;
/**
* Decodes the PVR2 data.
* @param {Uint8Array} data - The byte array containing the data.
* @returns {MemoryImage | undefined} The decoded MemoryImage or undefined if invalid.
*/
private decodePvr2;
/**
* Decodes the PVR3 data.
* @param {Uint8Array} data - The byte array containing the data.
* @returns {MemoryImage | undefined} The decoded MemoryImage or undefined if invalid.
*/
private decodePvr3;
/**
* Counts the number of bits set to 1 in the binary representation of a number.
* @param {number} x - The number to count bits in.
* @returns {number} The number of bits set to 1.
*/
private countBits;
/**
* Decodes a 4bpp RGB image.
* @param {number} width - The width of the image.
* @param {number} height - The height of the image.
* @param {TypedArray} data - The image data.
* @returns {MemoryImage} The decoded MemoryImage.
*/
private decodeRgb4bpp;
/**
* Decodes a 4bpp RGBA image.
* @param {number} width - The width of the image.
* @param {number} height - The height of the image.
* @param {TypedArray} data - The image data.
* @returns {MemoryImage} The decoded MemoryImage.
*/
private decodeRgba4bpp;
/**
* Checks if the given file is valid.
* @param {Uint8Array} bytes - The file data.
* @returns {boolean} True if the file is valid, false otherwise.
*/
isValidFile(bytes: Uint8Array): boolean;
/**
* Starts decoding the given file.
* @param {Uint8Array} bytes - The file data.
* @returns {PvrAppleInfo | Pvr3Info | Pvr2Info | undefined} The decoded PvrAppleInfo, Pvr3Info, Pvr2Info, or undefined if decoding fails.
*/
startDecode(bytes: Uint8Array): PvrAppleInfo | Pvr3Info | Pvr2Info | undefined;
/**
* Decodes the PVR file into a MemoryImage.
* @param {DecoderDecodeOptions} opt - The decoding options.
* @param {Uint8Array} opt.bytes - The file data.
* @param {number} [opt.frameIndex] - The frame index to decode (optional).
* @returns {MemoryImage | undefined} The decoded MemoryImage or undefined if decoding fails.
*/
decode(opt: DecoderDecodeOptions): MemoryImage | undefined;
/**
* Decodes a specific frame.
* @param {number} _frameIndex - The index of the frame to decode.
* @returns {MemoryImage | undefined} The decoded MemoryImage or undefined if decoding fails.
*/
decodeFrame(_frameIndex: number): MemoryImage | undefined;
}