@itwin/core-backend
Version:
iTwin.js backend components
49 lines • 2.58 kB
TypeScript
/** @packageDocumentation
* @module Images
*/
import { BinaryImageSource, ImageBuffer, ImageBufferFormat, ImageSourceFormat } from "@itwin/core-common";
/** Arguments supplied to [[imageBufferFromImageSource]].
* @public
*/
export interface ImageBufferFromImageSourceArgs {
/** The encoded image to be decoded into an [ImageBuffer]($common). */
source: BinaryImageSource;
/** The desired format for the decoded [ImageBuffer]($common).
* If unspecified, it defaults to [ImageBufferFormat.Rgb]($common) unless an alpha channel is present in [[source]].
*/
targetFormat?: ImageBufferFormat.Rgb | ImageBufferFormat.Rgba;
}
/** Decode a [BinaryImageSource]($common) into an [ImageBuffer]($common).
* Returns `undefined` if decoding fails, typically because the input was invalid.
* @see [[imageSourceFromImageBuffer]] for the inverse conversion.
* @public
*/
export declare function imageBufferFromImageSource(args: ImageBufferFromImageSourceArgs): ImageBuffer | undefined;
/** Arguments supplied to [[imageSourceFromImageBuffer]].
* @public
*/
export interface ImageSourceFromImageBufferArgs {
/** The image to be encoded.
* The image must be in [ImageBufferFormat.Rgb]($common) or [ImageBufferFormat.Rgba]($common) - [ImageBufferFormat.Alpha]($common) cannot be converted to an [ImageSource]($common).
*/
image: ImageBuffer;
/** The desired encoding for the resultant [BinaryImageSource]($common).
* Defaults to [ImageSourceFormat.Jpeg]($common) unless an alpha channel is present in [[image]].
*/
targetFormat?: ImageSourceFormat.Png | ImageSourceFormat.Jpeg;
/** If true, invert the order of the rows of the encoded image. */
flipVertically?: boolean;
/** If [[targetFormat]] is (or defaults to) [ImageSourceFormat.Jpeg]($common), an integer between 0 and 100 indicating
* the desired trade-off between image compression and image fidelity. This is a scale where 0 sacrifices image quality
* in favor of minimizing the size of the encoded image, and 100 minimizes compression artifacts at the expense of size.
* Default: 100.
*/
jpegQuality?: number;
}
/** Encode an [ImageBuffer]($common) into a [BinaryImageSource]($common).
* Returns `undefined` if encoding fails, typically because the input was invalid.
* @throws Error if the ImageBuffer is of [ImageBufferFormat.Alpha]($common).
* @public
*/
export declare function imageSourceFromImageBuffer(args: ImageSourceFromImageBufferArgs): BinaryImageSource | undefined;
//# sourceMappingURL=ImageSourceConversion.d.ts.map