import { ByteVector } from "../byteVector"; import { IVideoCodec, MediaTypes } from "../properties"; /** * This class provides a representation of a Microsoft BitmapInfoHeader structure which provides * information about the dimensions and color format of a device-independent bitmap. * @link https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapinfoheader */ export default class RiffBitmapInfoHeader implements IVideoCodec { /** * List of well known FOURCC codes and what they correspond to. * @remarks * This list was cobbled together using * * The original .NET source * * https://omiod.com/codec/list.php * * https://www.fourcc.org/ * * http://abcavi.kibi.ru/fourcc.php * If any FOURCCs are missing or wrong, submit a PR and include a link to some source saying * this FOURCC exists. */ static readonly FOURCC_CODES: Map; private readonly _bitCount; private readonly _colorsUsed; private readonly _compressionId; private readonly _height; private readonly _imageSize; private readonly _importantColors; private readonly _planes; private readonly _width; private readonly _xPixelsPerMeter; private readonly _yPixelsPerMeter; /** * Constructs and initializes a new instance by reading the raw structure from a specified * position in the provided {@link ByteVector}. * @param data ByteVector containing the raw data structure * @param offset Index into `data` where the raw bitmap info header begins. Must be a positive, * 32-bit integer. */ constructor(data: ByteVector, offset: number); /** * Gets the number of bits per pixel (bpp). For uncompressed formats, this value is the average * number of bits per pixel. For compressed formats, this value is the implied bit depth of the * uncompressed image, after the image has been decoded. */ get bitCount(): number; /** * Gets the number of color indices in the color table that are actually used by the bitmap. */ get colorsUsed(): number; /** * Gets the compression ID for the image. * @remarks * For compressed video and YUV formats, this is a FOURCC code, specified as a DWORD in * little-endian order. For more information, see * {@link https://docs.microsoft.com/en-us/windows/win32/directshow/fourcc-codes} and * {@link https://www.fourcc.org/fourcc.php}. For uncompressed RGB formats, the following * values are possible: * * `BI_RGB` = `0x00000000` => Uncompressed RGB * * `BI_BITFIELDS` = `0x00000003` => Uncompressed RGB with color masks, valid for 16 and * 32 bpp bitmaps. * * {@link description} makes a best-guess attempt to determine the name of the compression * codec used. */ get compressionId(): number; /** @inheritDoc */ get description(): string; /** * @inheritDoc * @remarks The duration is not known from the video codec in a RIFF format file. */ get durationMilliseconds(): number; /** * Gets the size, in bytes, of the image. This can be set to 0 for uncompressed RGB bitmaps. */ get imageSize(): number; /** * Gets the number of color indices that are considered important for displaying the bitmap. If * this value is `0`, all colors are important. */ get importantColors(): number; /** @inheritDoc */ get mediaTypes(): MediaTypes; /** * Gets the number of planes in the image. This value is pretty much universally set to 1. */ get planes(): number; /** @inheritDoc */ get videoHeight(): number; /** @inheritDoc */ get videoWidth(): number; /** * Gets the horizontal resolution, in pixels per meter, of the target device for the bitmap. */ get xPixelsPerMeter(): number; /** * Gets the vertical resolution, in pixels per meter, of the target device for the bitmap. */ get yPixelsPerMeter(): number; }