/** @packageDocumentation
 * @module Rendering
 */
import { Point2d } from "@itwin/core-geometry";
import { ImageBuffer, ImageBufferFormat, ImageSource, ImageSourceFormat } from "@itwin/core-common";
import { ViewRect } from "./ViewRect";
/** Resize a canvas to a desired size.  The final size will be targetSize plus barSize.  The original canvas is left untouched and a new, resized canvas with potential side bars is returned.
 * @param canvasIn the source [HTMLCanvasElement](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement) to resize.
 * @param targetSize the desired new size for the canvas image.
 * @param barSize total size of side bars to add to the image in width and height; defaults to (0, 0).  For example, if you specify (2, 0), a 1 pixel side bar will be added to the left and right sides of the resized image.  If an odd dimension is specified, the left or upper side of the image will be one pixel larger than the opposite side.  For example, if you specify (1, 0), a 1 pixel side bar will be added to the left side of the image and a 0 pixel side bar will be added to the right side of the image.
 * @param barStyle CSS style string to apply to any side bars; defaults to "#C0C0C0", which is silver.
 * @returns an [HTMLCanvasElement](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement) object containing the resized image and any requested side bars.
 * @public
 * @extensions
 */
export declare function canvasToResizedCanvasWithBars(canvasIn: HTMLCanvasElement, targetSize: Point2d, barSize?: Point2d, barStyle?: string): HTMLCanvasElement;
/** Create a canvas element with the same dimensions and contents as an image buffer.
 * @param buffer the source [[ImageBuffer]] object from which the [HTMLCanvasElement](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement) object will be constructed.
 * @param preserveAlpha If false, the alpha channel will be set to 255 (fully opaque). This is recommended when converting an already-blended image (e.g., one obtained from [[Viewport.readImageBuffer]]).
 * @returns an [HTMLCanvasElement](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement) object containing the contents of the source image buffer, or undefined if the conversion fails.
 * @public
 * @extensions
 */
export declare function imageBufferToCanvas(buffer: ImageBuffer, preserveAlpha?: boolean): HTMLCanvasElement | undefined;
/** Create an ImageBuffer in the specified format with the same dimensions and contents as a canvas.
 * @param canvas the source [HTMLCanvasElement](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement) object from which the [[ImageBuffer]] object will be constructed.
 * @param format the desired format of the created ImageBuffer; defaults to [[ImageBufferFormat.Rgba]].
 * @returns an [[ImageBuffer]] object containing the contents of the source canvas, or undefined if the conversion fails.
 * @public
 * @extensions
 */
export declare function canvasToImageBuffer(canvas: HTMLCanvasElement, format?: ImageBufferFormat): ImageBuffer | undefined;
/** Get a string describing the mime type associated with an ImageSource format.
 * @public
 * @extensions
 */
export declare function getImageSourceMimeType(format: ImageSourceFormat): string;
/** Get the ImageSourceFormat corresponding to the mime type string, or undefined if the string does not identify a supported ImageSourceFormat.
 * @public
 * @extensions
 */
export declare function getImageSourceFormatForMimeType(mimeType: string): ImageSourceFormat | undefined;
/** Extract an html Image element from a binary jpeg or png.
 * @param source The ImageSource containing the binary jpeg or png data.
 * @returns a Promise which resolves to an HTMLImageElement containing the uncompressed bitmap image in RGBA format.
 * @public
 * @extensions
 */
export declare function imageElementFromImageSource(source: ImageSource): Promise<HTMLImageElement>;
/** Extract a bitmap from a binary jpeg or png.
 * @param source The ImageSource containing the binary jpeg or png data.
 * @returns a Promise which resolves to an ImageBitmap containing the uncompressed bitmap image in RGBA format.
 * @public
 */
export declare function imageBitmapFromImageSource(source: ImageSource): Promise<ImageBitmap>;
/** Create an html Image element from a URL.
 * @param url The URL pointing to the image data.
 * @param skipCrossOriginCheck Set this to true to allow an image from a different origin than the web app to load. Default is false.
 * @returns A Promise resolving to an HTMLImageElement when the image data has been loaded from the URL.
 * @see tryImageElementFromUrl.
 * @public
 * @extensions
 */
export declare function imageElementFromUrl(url: string, skipCrossOriginCheck?: boolean): Promise<HTMLImageElement>;
/** Try to create an html Image element from a URL.
 * @param url The URL pointing to the image data.
 * @param skipCrossOriginCheck Set this to true to allow an image from a different origin than the web app to load. Default is false.
 * @returns A Promise resolving to an HTMLImageElement when the image data has been loaded from the URL, or to `undefined` if an exception occurred.
 * @see imageElementFromUrl
 * @public
 */
export declare function tryImageElementFromUrl(url: string, skipCrossOriginCheck?: boolean): Promise<HTMLImageElement | undefined>;
/**
 * Extract the dimensions of the jpeg or png data encoded in an ImageSource.
 * @param source The ImageSource containing the binary jpeg or png data.
 * @returns a Promise resolving to a Point2d of which x corresponds to the integer width of the uncompressed bitmap and y to the height.
 * @public
 * @extensions
 */
export declare function extractImageSourceDimensions(source: ImageSource): Promise<Point2d>;
/**
 * Produces a data url in "image/png" format from the contents of an ImageBuffer.
 * @param buffer The ImageBuffer, of any format.
 * @param preserveAlpha If false, the alpha channel will be set to 255 (fully opaque). This is recommended when converting an already-blended image (e.g., one obtained from [[Viewport.readImageBuffer]]).
 * @returns a data url as a string suitable for setting as the `src` property of an HTMLImageElement, or undefined if the url could not be created.
 * @public
 * @extensions
 */
export declare function imageBufferToPngDataUrl(buffer: ImageBuffer, preserveAlpha?: boolean): string | undefined;
/**
 * Converts the contents of an ImageBuffer to PNG format.
 * @param buffer The ImageBuffer, of any format.
 * @param preserveAlpha If false, the alpha channel will be set to 255 (fully opaque). This is recommended when converting an already-blended image (e.g., one obtained from [[Viewport.readImageBuffer]]).
 * @returns a base64-encoded string representing the image as a PNG, or undefined if the conversion failed.
 * @public
 * @extensions
 */
export declare function imageBufferToBase64EncodedPng(buffer: ImageBuffer, preserveAlpha?: boolean): string | undefined;
/** Open an image specified as a data URL in a new window or tab. Works around differences between browsers and Electron.
 * @param url The base64-encoded image URL.
 * @param title An optional title to apply to the new window.
 * @beta
 */
export declare function openImageDataUrlInNewWindow(url: string, title?: string): void;
/** Determine the maximum [[ViewRect]] that can be fitted and centered in specified ViewRect given a required aspect ratio.
 * @param viewRect The rectangle in which the returned rectangle is to be centered and fitted.
 * @param aspectRatio Ratio of width to height.
 * @returns A ViewRect centered in the input rectangle.
 * @public
 */
export declare function getCenteredViewRect(viewRect: ViewRect, aspectRatio?: number): ViewRect;
/** Produce a jpeg compressed to no more than specified bytes and of no less than specified quality.
 * @param canvas Canvas containing the image to be compressed.
 * @param maxBytes Maximum size of output jpeg in bytes.
 * @param minCompressionQuality The minimum acceptable image quality as a number between 0 (lowest quality) and 1 (highest quality).
 * @returns A [data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) for the image, or `undefined` if the compression and size constraints could not be met.
 * @public
 * @extensions
 */
export declare function getCompressedJpegFromCanvas(canvas: HTMLCanvasElement, maxBytes?: number, minCompressionQuality?: number): string | undefined;
//# sourceMappingURL=ImageUtil.d.ts.map