import * as em from "./Enums"; import * as ds from "./Types"; import { ObjectManager } from "./ObjectManager"; import { ObjectBase } from "./ObjectBase"; import { type BilevelBitmap } from "./BilevelBitmap"; import { type GrayscaleBitmap } from "./GrayscaleBitmap"; import { type BmpContext } from "./BmpContext"; import { type Image } from "./Image"; /** * Represents an uncompressed in-memory bitmap. **/ export declare class Bitmap extends ObjectBase { /** * Creates a {@link Bitmap} instance with optionally initialized pixels. * @param width The bitmap width, in pixels. * @param height The bitmap height, in pixels. * @param backColor The optional background color to fill the {@link Bitmap}. **/ constructor(width: number, height: number, backColor?: ds.Color | null); /** * Creates a {@link Bitmap} instance with optionally initialized pixels. * @param om An object manager that controls the lifetime of the {@link Bitmap} object. * @param width The bitmap width, in pixels. * @param height The bitmap height, in pixels. * @param backColor The optional background color to fill the {@link Bitmap}. **/ constructor(om: ObjectManager, width: number, height: number, backColor?: ds.Color | null); /** * Gets the width of the bitmap, in pixels. **/ get width(): number; /** * Gets the height of the bitmap, in pixels. **/ get height(): number; /** * Gets the current {@link BmpContext} for this {@link Bitmap}. **/ get context(): BmpContext; /** * Creates a {@link BmpContext} for the current Bitmap and optionally fills it with a background color. * @param bmpContextProperties The settings for creating a {@link DrawingContext} for {@link Bitmap}. * @returns An instance of BmpContext. **/ newContext(bmpContextProperties?: ds.BmpContextProperties): BmpContext; /** * Saves the {@link Bitmap} as an array with PNG-encoded image data. * @param [fastest=false] if true, forces the operation to work as fast as possible at the expence of lower compression ratio. * @return A byte array with PNG-encoded image data. **/ saveAsPng(fastest?: boolean): Uint8Array; /** * Saves the {@link Bitmap} as an array with JPEG-encoded image data. * @param [quality=90] The image quality from 0 (best compression) to 100 (best quality). * @return A byte array with JPEG-encoded image data. **/ saveAsJpeg(quality?: number): Uint8Array; /** * Saves the {@link Bitmap} as a PNG-encoded Image. * @param [fastest=false] if true, forces the operation to work as fast as possible at the expence of lower compression ratio. * @returns The resulting Image object. **/ saveAsPngImage(fastest?: boolean): Image; /** * Saves the {@link Bitmap} as a JPEG-encoded Image. * @param [quality=90] The image quality from 0 (best compression) to 100 (best quality). * @returns The resulting Image object. **/ saveAsJpegImage(quality?: number): Image; /** * Returns the coordinates of a rectangle with colors different from backColor. * @param backColor The background color. * @returns A part of the image rectangle excluding the margins with background color. **/ getContentRect(backColor: ds.Color): ds.Rect | null; /** * Clears the whole {@link Bitmap} or its part with specified color. * @param color The color to fill the image. * @param bounds The target rectangle of the Bitmap. **/ clear(color: ds.Color, bounds?: ds.Bounds | null): void; /** * Creates a new {@link Bitmap} with a copy of the image. * @param [metadataOnly=false] specifies whether to copy the image metadata only, not actual pixel data. * @returns A new {@link Bitmap} with a copy of the source image. **/ clone(metadataOnly?: boolean): Bitmap; /** * Creates a new {@link Bitmap} with a fragment of the image. * @param x The X coordinate of the clipping rectangle. * @param y The Y coordinate of the clipping rectangle. * @param width The width of the clipping rectangle. * @param height The height of the clipping rectangle. * @param metadataOnly Specifies whether to copy the image metadata only, not actual pixel data. The default is false. * @returns A new {@link Bitmap} with a fragment of the source image. **/ clip(x: number, y: number, width: number, height: number, metadataOnly?: boolean): Bitmap; /** * Creates a new {@link Bitmap} with a fragment of the image. * @param bounds Clipping rectangle of the source image to be extracted as a new {@link Bitmap}. * @param metadataOnly Specifies whether to copy the image metadata only, not actual pixel data. The default is false. * @returns A new {@link Bitmap} with a fragment of the source image. **/ clip(bounds: ds.Bounds, metadataOnly?: boolean): Bitmap; /** * Produces a flipped (horizontal or vertical) and/or rotated (by 90 degree increments) bitmap. * The source {@link Bitmap} remains unchanged. * @param action The operation to be applied. * @param clipBounds Clipping rectangle specifying the area of the source image to be processed. * @returns A new {@link Bitmap} with transformed image. **/ flipRotate(action: em.FlipRotateAction, clipBounds?: ds.Bounds | null): Bitmap; /** * Creates a new {@link Bitmap} with a resized image fragment. * The source Bitmap remains unchanged. * @param width The width of the resized image, in pixels. * @param height The height of the resized image, in pixels. * @param interpolationMode The interpolation mode to use when scaling. The default is Linear. * @returns A new {@link Bitmap} with resized image. **/ resize(width: number, height: number, interpolationMode?: em.InterpolationMode): Bitmap; /** * Creates a new {@link Bitmap} with a resized image fragment. * The source Bitmap remains unchanged. * @param options The resizing options. * @returns A new {@link Bitmap} with resized image. **/ resize(options: ds.ResizeBitmapOptions): Bitmap; /** * Returns true if all pixels in the image are either black or white. **/ get blackAndWhite(): boolean; /** * Creates a {@link BilevelBitmap} from the current {@link Bitmap}. * This method does not perform any transformations of the color palette. * It is expected that the source {@link Bitmap} has already been converted * to bi-level palette using some thresholding or dithering effects. * The toBilevelBitmap method just copies data from a specified color * channel to a new instance of the {@link BilevelBitmap} class. * @param colorChannel The color channel used as the source of the bi-level data. * @param [lowerBitsFirst=false] If true, pixels are arranged within a byte such that pixels with lower column indices are stored in the lower-order bits of the byte. * @param [whiteIsZero=false] If true, indicates that 0 represents white and 1 represents black in the resulting {@link BilevelBitmap}. * @returns A new instance of {@link BilevelBitmap}. **/ toBilevelBitmap(colorChannel?: em.ColorChannel, lowerBitsFirst?: boolean, whiteIsZero?: boolean): BilevelBitmap; /** * Determines whether the image contains only opaque grayscale pixels. **/ get grayscale(): boolean; /** * Creates a {@link GrayscaleBitmap} from the current {@link Bitmap}. * This method does not perform any transformations of the color palette. * It is expected that the source {@link Bitmap} has already been converted to * grayscale palette using the {@link Bitmap#applyGrayscaleEffect} or something like that. * Alternatively, you can use this method to extract individual channels of * a color image without any prior conversion, and treat the resulting GrayscaleBitmap * simply as a representation of some image data with 8 bits per pixel. * The toGrayscaleBitmap method just copies data from a specified color * channel to a new instance of the GrayscaleBitmap class. * @param colorChannel The color channel used as the source of grayscale data. * @param [whiteIsZero=false] If true, indicates that 0 represents white and 255 represents black in the resulting {@link GrayscaleBitmap}. * @returns A new instance of {@link GrayscaleBitmap}. **/ toGrayscaleBitmap(colorChannel?: em.ColorChannel, whiteIsZero?: boolean): GrayscaleBitmap; /** * Applies a bi-level transparency mask to the current image or its portion. * @param mask A {@link BilevelBitmap} with the transparency mask. * @param bounds The target rectangle of the bitmap. **/ applyBilevelTransparencyMask(mask: BilevelBitmap, bounds?: ds.Bounds | null): void; /** * Applies a grayscale transparency mask to the current image or its portion. * @param mask A {@link GrayscaleBitmap} with the transparency mask. * @param bounds The target rectangle of the bitmap. **/ applyGrayscaleTransparencyMask(mask: GrayscaleBitmap, bounds?: ds.Bounds | null): void; /** * Converts an image with transparent or semitransparent pixels to fully opaque with specified background color. * @param backColor The color to be used as background for transparent pixels. * @param bounds The target rectangle of the bitmap. **/ convertToOpaque(backColor: ds.Color, bounds?: ds.Bounds | null): void; /** * Determines whether the image contains transparent or semitransparent pixels. * @param bounds The source rectangle to analyse. * @returns true if at least one non-opaque pixel was found, false otherwise. **/ hasTransparentPixels(bounds?: ds.Bounds | null): boolean; /** * Applies the in-place effect that updates the image brightness and contrast. * @param brightness A value from -255 to 255 for adjusting the brightness level. * @param contrast A value from -255 to 255 for adjusting the contrast level. * @param bounds The target rectangle of the {@link Bitmap}, or the entire {@link Bitmap} if null. **/ applyBrightnessContrast(brightness: number, contrast: number, bounds?: ds.Bounds | null): void; /** * Applies the in-place effect that converts a monochromatic (grayscale) image to bi-level image using Bradley and Roth's method of adaptive image thresholding. * @param [sDivider=8] A divider of the image width to calculate the value of s. * @param [t=15] The value of t parameter. * @param bounds The target rectangle of the {@link Bitmap}, or the entire {@link Bitmap} if null. **/ applyBradleyThresholdingEffect(sDivider?: number, t?: number, bounds?: ds.Bounds | null): void; /** * Applies the in-place effect that converts a monochromatic (grayscale) image to bi-level image with two-dimensional error diffusion dithering. * @param ditheringMethod The method of two-dimensional error diffusion dithering. The default is Floyd-Steinberg method. * @param bounds The target rectangle of the {@link Bitmap}, or the entire {@link Bitmap} if null. **/ applyDitheringEffect(ditheringMethod?: em.DitheringMethod, bounds?: ds.Bounds | null): void; /** * Applies the in-place effect that applies gamma correction to the image. * @param [gamma=2.2] A value of Gamma, from 0.001 to 1000. * @param bounds The target rectangle of the {@link Bitmap}, or the entire {@link Bitmap} if null. **/ applyGammaCorrection(gamma?: number, bounds?: ds.Bounds | null): void; /** * Applies the in-place effect that applies a Gaussian blur to the image. * @param [radius=9] The radius of the blur, in pixels. * @param borderMode The mapping mode for the pixels outside of the border, "RepeatEdge" if null. * @param borderColor The color used to blend with the edge pixels of the image, "Transparent" if null. * @param bounds The target rectangle of the {@link Bitmap}, or the entire {@link Bitmap} if null. **/ applyGaussianBlur(radius?: number, borderMode?: em.GaussianBlurBorderMode | null, borderColor?: ds.Color | null, bounds?: ds.Bounds | null): void; /** * Applies the in-place effect that converts an image to monochromatic gray. * @param standard A grayscale standard used for converting full-color image to monochromatic gray. * @param bounds The target rectangle of the {@link Bitmap}, or the entire {@link Bitmap} if null. **/ applyGrayscaleEffect(standard?: em.GrayscaleStandard, bounds?: ds.Bounds | null): void; /** * Applies the in-place effect that alters the hue of an image based on the rotation angle. * @param angleInDegrees The angle to rotate the hue, in degrees. * @param bounds The target rectangle of the {@link Bitmap}, or the entire {@link Bitmap} if null. **/ applyHueRotation(angleInDegrees: number, bounds?: ds.Bounds | null): void; /** * Applies the in-place effect that sets the alpha channel to the luminance of the image and sets the color channels to 0. * @param bounds The target rectangle of the {@link Bitmap}, or the entire {@link Bitmap} if null. **/ applyLuminanceToAlpha(bounds?: ds.Bounds | null): void; /** * Applies the in-place effect that adjusts the opacity of an image by multiplying the alpha channel of the input by the specified opacity value. * @param opacity The multiplier to the input image's alpha channel. The minimum value is 0.0 and the maximum value is 1.0. * @param bounds The target rectangle of the {@link Bitmap}, or the entire {@link Bitmap} if null. **/ applyOpacityEffect(opacity: number, bounds?: ds.Bounds | null): void; /** * Applies the in-place effect that converts a monochromatic (grayscale) image to bi-level image using Otsu's method of clustering-based image thresholding. * @param bounds The target rectangle of the {@link Bitmap}, or the entire {@link Bitmap} if null. **/ applyOtsuThresholdingEffect(bounds?: ds.Bounds | null): void; /** * Applies the in-place effect that alters the saturation of an image. * @param saturation The saturation of the image between 0.0 (monochrome) and 1.0 (fully saturated). * @param bounds The target rectangle of the {@link Bitmap}, or the entire {@link Bitmap} if null. **/ applySaturationEffect(saturation: number, bounds?: ds.Bounds | null): void; /** * Applies the in-place effect that converts an image to sepia tones. * @param bounds The target rectangle of the {@link Bitmap}, or the entire {@link Bitmap} if null. **/ applySepiaEffect(bounds?: ds.Bounds | null): void; /** * Applies the in-place effect that alters the temperature and tint of an image. * @param temperature Specifies how much to increase or decrease the temperature of the input image. The allowed range is between -1.0 and 1.0. * @param tint Specifies how much to increase or decrease the tint of the input image. The allowed range is between -1.0 and 1.0. * @param bounds The target rectangle of the {@link Bitmap}, or the entire {@link Bitmap} if null. **/ applyTemperatureAndTint(temperature: number, tint: number, bounds?: ds.Bounds | null): void; /** * Performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source bitmap into the current {@link Bitmap}. * @param srcBitmap The {@link Bitmap} with the source color data to transfer. * @param dstX The x-coordinate of the destination rectangle, in pixels. * @param dstY The y-coordinate of the destination rectangle, in pixels. * @param options The source coordinates, size, and other options. **/ bitBlt(srcBitmap: Bitmap, dstX: number, dstY: number, options?: ds.BitBltOptions): void; /** * Draws the source bitmap with the specified opacity into the current {@link Bitmap}. * @param srcBitmap The {@link Bitmap} with the source color data to draw. * @param dstX The x-coordinate of the destination rectangle, in pixels. * @param dstY The y-coordinate of the destination rectangle, in pixels. * @param options The alpha blend options. **/ alphaBlend(srcBitmap: Bitmap, dstX: number, dstY: number, options?: ds.AlphaBlendOptions): void; /** * Applies the algorithms of Porter Duff compositing and blending to the current {@link Bitmap} (used as backdrop, destination) and the source {@link Bitmap}. * @param srcBitmap The {@link Bitmap} with the source color data to composite. * @param dstX The x-coordinate of the destination rectangle, in pixels. * @param dstY The y-coordinate of the destination rectangle, in pixels. * @param options The compositing and blending options. **/ compositeAndBlend(srcBitmap: Bitmap, dstX: number, dstY: number, options?: ds.CompositeAndBlendOptions): void; /** * Copies data from one color channel of the current {@link Bitmap} to an existing {@link GrayscaleBitmap} of the same pixel size. * @param destination The target {@link GrayscaleBitmap}. * @param colorChannel A channel of the source {@link Bitmap} to be exported. **/ exportColorChannel(destination: GrayscaleBitmap, colorChannel: em.ColorChannel): void; /** * Copies data from a {@link GrayscaleBitmap} to one color channel of the current {@link Bitmap} of the same pixel size. * @param source A {@link GrayscaleBitmap} with source data. * @param colorChannel A channel of the destination {@link Bitmap} to be updated. **/ importColorChannel(source: GrayscaleBitmap, colorChannel: em.ColorChannel): void; /** * Modifies R, G, B color intensities such that the maximum range of values (0..255) is fully covered. * @param [keepRelativeIntensities=true] Indicates if the method should keep the relative intensities of the color channels unchanged. * @param [lowClipFraction=0.002] The fraction of extremely low values to be clipped, not greater than 0.1. * @param [highClipFraction=0.002] The fraction of extremely high values to be clipped, not greater than 0.1. **/ autoLevels(keepRelativeIntensities?: boolean, lowClipFraction?: number, highClipFraction?: number): void; /** * Adjusts the levels of an image histogram. * The method maps the input range of values (blackPoint..whitePoint) to the output * range (outputBlack..outputWhite) using the specified gamma correction (midtone). * @param blackPoint The input black point color. * @param whitePoint The input white point color. * @param outputBlack The output black point color. * @param outputWhite The output white point color. * @param [midtone=1.0] The value of gamma correction. **/ adjustLevels(blackPoint: ds.Color, whitePoint: ds.Color, outputBlack: ds.Color, outputWhite: ds.Color, midtone?: number): void; /** * Creates a bitmap with shadow from the current image. * The shadow appears only if some pixels of the current image are transparent or semi-transparent. * @param xOffset The horizontal offset of the shadow, in pixels. * @param yOffset The vertical offset of the shadow, in pixels. * @param shadowColor The shadow color. * @param [shadowOpacity=0.6] The shadow opacity, between 0 and 1. * @param [gaussianBlurRadius=9] The shadow blur radius, in pixels. * @returns A new {@link Bitmap} with shadow. **/ addShadow(xOffset: number, yOffset: number, shadowColor: ds.Color, shadowOpacity?: number, gaussianBlurRadius?: number): Bitmap; /** * Creates a bitmap with glow effect from the current image. * The glow effect inflates all non-transparent areas of an image by a specified amount, then applies a Gaussian blur to make the border smooth. * The effect appears only if some pixels of the current image are transparent or semi-transparent. * @param glowColor The glow color. * @param [glowOpacity=0.8] The glow opacity, between 0 and 1. * @param [inflationRadius=6] The glow inflation radius, in pixels. * @param [gaussianBlurRadius=9] The Gaussian blur radius, in pixels. * @returns A new {@link Bitmap} with glow effect. **/ addGlow(glowColor: ds.Color, glowOpacity?: number, inflationRadius?: number, gaussianBlurRadius?: number): Bitmap; /** * Applies a soft edges effect to the current image. * The soft edges effect deflates all non-transparent areas of an image by a specified amount, then applies a Gaussian blur to make the border smooth. * @param [inflationRadius=-6] The negative radius of inflation, in pixels. * @param [gaussianBlurRadius=9] The Gaussian blur radius, in pixels. **/ applySoftEdges(inflationRadius?: number, gaussianBlurRadius?: number): void; }