DsPdfJS API - v9.1.0
    Preparing search index...

    Class Bitmap

    Represents an uncompressed in-memory bitmap.

    Hierarchy (View Summary)

    Index

    Constructors

    • Creates a Bitmap instance with optionally initialized pixels.

      Parameters

      • width: number

        The bitmap width, in pixels.

      • height: number

        The bitmap height, in pixels.

      • OptionalbackColor: Color | null

        The optional background color to fill the Bitmap.

      Returns Bitmap

    • Creates a Bitmap instance with optionally initialized pixels.

      Parameters

      • om: ObjectManager

        An object manager that controls the lifetime of the Bitmap object.

      • width: number

        The bitmap width, in pixels.

      • height: number

        The bitmap height, in pixels.

      • OptionalbackColor: Color | null

        The optional background color to fill the Bitmap.

      Returns Bitmap

    Accessors

    • get blackAndWhite(): boolean

      Returns true if all pixels in the image are either black or white.

      Returns boolean

    • get grayscale(): boolean

      Determines whether the image contains only opaque grayscale pixels.

      Returns boolean

    • get height(): number

      Gets the height of the bitmap, in pixels.

      Returns number

    • get id(): number

      Gets the reference to the object.

      Returns number

    • get width(): number

      Gets the width of the bitmap, in pixels.

      Returns number

    Methods

    • 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.

      Parameters

      • glowColor: Color

        The glow color.

      • OptionalglowOpacity: number = 0.8

        The glow opacity, between 0 and 1.

      • OptionalinflationRadius: number = 6

        The glow inflation radius, in pixels.

      • OptionalgaussianBlurRadius: number = 9

        The Gaussian blur radius, in pixels.

      Returns Bitmap

      A new Bitmap with glow effect.

    • 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.

      Parameters

      • xOffset: number

        The horizontal offset of the shadow, in pixels.

      • yOffset: number

        The vertical offset of the shadow, in pixels.

      • shadowColor: Color

        The shadow color.

      • OptionalshadowOpacity: number = 0.6

        The shadow opacity, between 0 and 1.

      • OptionalgaussianBlurRadius: number = 9

        The shadow blur radius, in pixels.

      Returns Bitmap

      A new Bitmap with shadow.

    • 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).

      Parameters

      • blackPoint: Color

        The input black point color.

      • whitePoint: Color

        The input white point color.

      • outputBlack: Color

        The output black point color.

      • outputWhite: Color

        The output white point color.

      • Optionalmidtone: number = 1.0

        The value of gamma correction.

      Returns void

    • Draws the source bitmap with the specified opacity into the current Bitmap.

      Parameters

      • srcBitmap: Bitmap

        The Bitmap with the source color data to draw.

      • dstX: number

        The x-coordinate of the destination rectangle, in pixels.

      • dstY: number

        The y-coordinate of the destination rectangle, in pixels.

      • Optionaloptions: AlphaBlendOptions

        The alpha blend options.

      Returns void

    • Applies a bi-level transparency mask to the current image or its portion.

      Parameters

      Returns 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.

      Parameters

      • OptionalsDivider: number = 8

        A divider of the image width to calculate the value of s.

      • Optionalt: number = 15

        The value of t parameter.

      • Optionalbounds: Bounds | null

        The target rectangle of the Bitmap, or the entire Bitmap if null.

      Returns void

    • Applies the in-place effect that updates the image brightness and contrast.

      Parameters

      • brightness: number

        A value from -255 to 255 for adjusting the brightness level.

      • contrast: number

        A value from -255 to 255 for adjusting the contrast level.

      • Optionalbounds: Bounds | null

        The target rectangle of the Bitmap, or the entire Bitmap if null.

      Returns void

    • Applies the in-place effect that converts a monochromatic (grayscale) image to bi-level image with two-dimensional error diffusion dithering.

      Parameters

      • OptionalditheringMethod: DitheringMethod

        The method of two-dimensional error diffusion dithering. The default is Floyd-Steinberg method.

      • Optionalbounds: Bounds | null

        The target rectangle of the Bitmap, or the entire Bitmap if null.

      Returns void

    • Applies the in-place effect that applies gamma correction to the image.

      Parameters

      • Optionalgamma: number = 2.2

        A value of Gamma, from 0.001 to 1000.

      • Optionalbounds: Bounds | null

        The target rectangle of the Bitmap, or the entire Bitmap if null.

      Returns void

    • Applies the in-place effect that applies a Gaussian blur to the image.

      Parameters

      • Optionalradius: number = 9

        The radius of the blur, in pixels.

      • OptionalborderMode: GaussianBlurBorderMode | null

        The mapping mode for the pixels outside of the border, "RepeatEdge" if null.

      • OptionalborderColor: Color | null

        The color used to blend with the edge pixels of the image, "Transparent" if null.

      • Optionalbounds: Bounds | null

        The target rectangle of the Bitmap, or the entire Bitmap if null.

      Returns void

    • Applies the in-place effect that converts an image to monochromatic gray.

      Parameters

      • Optionalstandard: GrayscaleStandard

        A grayscale standard used for converting full-color image to monochromatic gray.

      • Optionalbounds: Bounds | null

        The target rectangle of the Bitmap, or the entire Bitmap if null.

      Returns void

    • Applies a grayscale transparency mask to the current image or its portion.

      Parameters

      Returns void

    • Applies the in-place effect that alters the hue of an image based on the rotation angle.

      Parameters

      • angleInDegrees: number

        The angle to rotate the hue, in degrees.

      • Optionalbounds: Bounds | null

        The target rectangle of the Bitmap, or the entire Bitmap if null.

      Returns void

    • Applies the in-place effect that sets the alpha channel to the luminance of the image and sets the color channels to 0.

      Parameters

      • Optionalbounds: Bounds | null

        The target rectangle of the Bitmap, or the entire Bitmap if null.

      Returns 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.

      Parameters

      • opacity: number

        The multiplier to the input image's alpha channel. The minimum value is 0.0 and the maximum value is 1.0.

      • Optionalbounds: Bounds | null

        The target rectangle of the Bitmap, or the entire Bitmap if null.

      Returns 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.

      Parameters

      • Optionalbounds: Bounds | null

        The target rectangle of the Bitmap, or the entire Bitmap if null.

      Returns void

    • Applies the in-place effect that alters the saturation of an image.

      Parameters

      • saturation: number

        The saturation of the image between 0.0 (monochrome) and 1.0 (fully saturated).

      • Optionalbounds: Bounds | null

        The target rectangle of the Bitmap, or the entire Bitmap if null.

      Returns void

    • Applies the in-place effect that converts an image to sepia tones.

      Parameters

      • Optionalbounds: Bounds | null

        The target rectangle of the Bitmap, or the entire Bitmap if null.

      Returns void

    • 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.

      Parameters

      • OptionalinflationRadius: number = -6

        The negative radius of inflation, in pixels.

      • OptionalgaussianBlurRadius: number = 9

        The Gaussian blur radius, in pixels.

      Returns void

    • Applies the in-place effect that alters the temperature and tint of an image.

      Parameters

      • temperature: number

        Specifies how much to increase or decrease the temperature of the input image. The allowed range is between -1.0 and 1.0.

      • tint: number

        Specifies how much to increase or decrease the tint of the input image. The allowed range is between -1.0 and 1.0.

      • Optionalbounds: Bounds | null

        The target rectangle of the Bitmap, or the entire Bitmap if null.

      Returns void

    • Modifies R, G, B color intensities such that the maximum range of values (0..255) is fully covered.

      Parameters

      • OptionalkeepRelativeIntensities: boolean = true

        Indicates if the method should keep the relative intensities of the color channels unchanged.

      • OptionallowClipFraction: number = 0.002

        The fraction of extremely low values to be clipped, not greater than 0.1.

      • OptionalhighClipFraction: number = 0.002

        The fraction of extremely high values to be clipped, not greater than 0.1.

      Returns void

    • Performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source bitmap into the current Bitmap.

      Parameters

      • srcBitmap: Bitmap

        The Bitmap with the source color data to transfer.

      • dstX: number

        The x-coordinate of the destination rectangle, in pixels.

      • dstY: number

        The y-coordinate of the destination rectangle, in pixels.

      • Optionaloptions: BitBltOptions

        The source coordinates, size, and other options.

      Returns void

    • Clears the whole Bitmap or its part with specified color.

      Parameters

      • color: Color

        The color to fill the image.

      • Optionalbounds: Bounds | null

        The target rectangle of the Bitmap.

      Returns void

    • Creates a new Bitmap with a fragment of the image.

      Parameters

      • bounds: Bounds

        Clipping rectangle of the source image to be extracted as a new Bitmap.

      • OptionalmetadataOnly: boolean = false

        Specifies whether to copy the image metadata only, not actual pixel data.

      Returns Bitmap

      A new Bitmap with a fragment of the source image.

    • Creates a new Bitmap with a copy of the image.

      Parameters

      • OptionalmetadataOnly: boolean = false

        specifies whether to copy the image metadata only, not actual pixel data.

      Returns Bitmap

      A new Bitmap with a copy of the source image.

    • Applies the algorithms of Porter Duff compositing and blending to the current Bitmap (used as backdrop, destination) and the source Bitmap.

      Parameters

      • srcBitmap: Bitmap

        The Bitmap with the source color data to composite.

      • dstX: number

        The x-coordinate of the destination rectangle, in pixels.

      • dstY: number

        The y-coordinate of the destination rectangle, in pixels.

      • Optionaloptions: CompositeAndBlendOptions

        The compositing and blending options.

      Returns void

    • Converts an image with transparent or semitransparent pixels to fully opaque with specified background color.

      Parameters

      • backColor: Color

        The color to be used as background for transparent pixels.

      • Optionalbounds: Bounds | null

        The target rectangle of the bitmap.

      Returns void

    • Produces a flipped (horizontal or vertical) and/or rotated (by 90 degree increments) bitmap. The source Bitmap remains unchanged.

      Parameters

      • action: FlipRotateAction

        The operation to be applied.

      • OptionalclipBounds: Bounds | null

        Clipping rectangle specifying the area of the source image to be processed.

      Returns Bitmap

      A new Bitmap with transformed image.

    • Detaches the object from the ObjectManager and deallocates its memory, if possible.

      Returns void

    • Returns the coordinates of a rectangle with colors different from backColor.

      Parameters

      • backColor: Color

        The background color.

      Returns Rect | null

      A part of the image rectangle excluding the margins with background color.

    • Determines whether the image contains transparent or semitransparent pixels.

      Parameters

      • Optionalbounds: Bounds | null

        The source rectangle to analyse.

      Returns boolean

      true if at least one non-opaque pixel was found, false otherwise.

    • Saves the Bitmap as an array with JPEG-encoded image data.

      Parameters

      • Optionalquality: number = 90

        The image quality from 0 (best compression) to 100 (best quality).

      Returns Uint8Array

      A byte array with JPEG-encoded image data.

    • Saves the Bitmap as a JPEG-encoded Image.

      Parameters

      • Optionalquality: number = 90

        The image quality from 0 (best compression) to 100 (best quality).

      Returns Image

      The resulting Image object.

    • Saves the Bitmap as an array with PNG-encoded image data.

      Parameters

      • Optionalfastest: boolean = false

        if true, forces the operation to work as fast as possible at the expence of lower compression ratio.

      Returns Uint8Array

      A byte array with PNG-encoded image data.

    • Saves the Bitmap as a PNG-encoded Image.

      Parameters

      • Optionalfastest: boolean = false

        if true, forces the operation to work as fast as possible at the expence of lower compression ratio.

      Returns Image

      The resulting Image object.

    • Creates a BilevelBitmap from the current Bitmap. This method does not perform any transformations of the color palette. It is expected that the source 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 BilevelBitmap class.

      Parameters

      • OptionalcolorChannel: ColorChannel

        The color channel used as the source of the bi-level data.

      • OptionallowerBitsFirst: boolean = 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.

      • OptionalwhiteIsZero: boolean = false

        If true, indicates that 0 represents white and 1 represents black in the resulting BilevelBitmap.

      Returns BilevelBitmap

      A new instance of BilevelBitmap.

    • Creates a GrayscaleBitmap from the current Bitmap. This method does not perform any transformations of the color palette. It is expected that the source Bitmap has already been converted to grayscale palette using the 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.

      Parameters

      • OptionalcolorChannel: ColorChannel

        The color channel used as the source of grayscale data.

      • OptionalwhiteIsZero: boolean = false

        If true, indicates that 0 represents white and 255 represents black in the resulting GrayscaleBitmap.

      Returns GrayscaleBitmap

      A new instance of GrayscaleBitmap.