UNPKG

@itwin/core-common

Version:

iTwin.js components common to frontend and backend

101 lines 3.99 kB
/** @packageDocumentation * @module Rendering */ /** Format of an [[ImageBuffer]]. * The format determines how many bytes are allocated for each pixel in the buffer and the semantics of each byte. * @see [[ImageBuffer.getNumBytesPerPixel]] * @public * @extensions */ export declare enum ImageBufferFormat { /** RGBA format - 4 bytes per pixel. */ Rgba = 0, /** RGB format - 3 bytes per pixel. */ Rgb = 2, /** 1 byte per pixel. */ Alpha = 5 } /** Uncompressed rectangular bitmap image data. * @public */ export declare class ImageBuffer { /** Image data in which each pixel occupies 1 or more bytes depending of the [[ImageBufferFormat]]. */ readonly data: Uint8Array; /** Format of the bytes in the image. */ readonly format: ImageBufferFormat; /** Width of image in pixels */ readonly width: number; /** Return the number of bytes allocated for each pixel. */ get numBytesPerPixel(): number; /** Determine the number of bytes allocated to a single pixel for the specified format. */ static getNumBytesPerPixel(format: ImageBufferFormat): number; /** Get the height of this image in pixels. */ get height(): number; /** Create a new ImageBuffer. * @note The ImageBuffer takes ownership of the input Uint8Array. * @param data The uncompressed image bytes. Must be a multiple of the width times the number of bytes per pixel specified by the format. * @param format The format of the image. * @param width The width of the image in pixels. * @returns A new ImageBuffer. * @throws Error if the length of the Uint8Array is not appropriate for the specified width and format. */ static create(data: Uint8Array, format: ImageBufferFormat, width: number): ImageBuffer; private static isValidData; private static computeHeight; private constructor(); } /** Returns whether the input is a power of two. * @note Floating point inputs are truncated. * @public */ export declare function isPowerOfTwo(num: number): boolean; /** Returns the first power-of-two value greater than or equal to the input. * @note Floating point inputs are truncated. * @public */ export declare function nextHighestPowerOfTwo(num: number): number; /** The format of an ImageSource. * @public * @extensions */ export declare enum ImageSourceFormat { /** Image data is stored with JPEG compression. */ Jpeg = 0, /** Image data is stored with PNG compression. */ Png = 2, /** Image is stored as an Svg stream. * @note SVG is only valid for ImageSources in JavaScript. It *may not* be used for persistent textures. */ Svg = 3 } /** Returns true if the numeric `format` value is a valid member of the [[ImageSourceFormat]] enumeration. * @public */ export declare function isValidImageSourceFormat(format: number): format is ImageSourceFormat; /** Image data encoded and compressed in either Jpeg or Png format. * @public */ export declare class ImageSource { /** The content of the image, compressed */ readonly data: Uint8Array | string; /** The compression type. */ readonly format: ImageSourceFormat; /** Construct a new ImageSource, which takes ownership of the Uint8Array. */ constructor(data: Uint8Array | string, format: ImageSourceFormat); } /** An [[ImageSource]] encoded in binary form as a Jpeg or Png, as opposed to one encoded * in string format as an Svg. * Only binary ImageSources can be used for [[Texture]]s stored in [[IModelDb]]s. * @public */ export interface BinaryImageSource { /** The format in which the [[data]] is encoded. */ readonly format: ImageSourceFormat.Jpeg | ImageSourceFormat.Png; /** The image data encoded according to [[format]]. */ readonly data: Uint8Array; } /** Returns true if `source` is a [[BinaryImageSource]]. * @public */ export declare function isBinaryImageSource(source: ImageSource): source is BinaryImageSource; //# sourceMappingURL=Image.d.ts.map