[]
        
(Showing Draft Content)

GrayscaleBitmap

DsPdfJS API v9.1.0


DsPdfJS API / GrayscaleBitmap

Class: GrayscaleBitmap

Represents a grayscale image or transparency mask with 8 bits per pixel.

Extends

Constructors

Constructor

new GrayscaleBitmap(width, height, gbProperties?): GrayscaleBitmap

Creates a GrayscaleBitmap instance with optionally initialized pixels.

Parameters

width

number

The grayscale bitmap width, in pixels.

height

number

The grayscale bitmap height, in pixels.

gbProperties?

GrayscaleBitmapProperties

The settings for creating a grayscale bitmap.

Returns

GrayscaleBitmap

Overrides

ObjectBase.constructor

Constructor

new GrayscaleBitmap(om, width, height, gbProperties?): GrayscaleBitmap

Creates a GrayscaleBitmap instance with optionally initialized pixels.

Parameters

om

ObjectManager

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

width

number

The grayscale bitmap width, in pixels.

height

number

The grayscale bitmap height, in pixels.

gbProperties?

GrayscaleBitmapProperties

The settings for creating a grayscale bitmap.

Returns

GrayscaleBitmap

Overrides

ObjectBase.constructor

Accessors

height

Get Signature

get height(): number

Gets the height of the GrayscaleBitmap, in pixels.

Returns

number


id

Get Signature

get id(): number

Gets the reference to the object.

Returns

number

Inherited from

ObjectBase.id


om

Get Signature

get om(): ObjectManager

Gets the owner ObjectManager instance.

Returns

ObjectManager

Inherited from

ObjectBase.om


transparencyMask

Get Signature

get transparencyMask(): boolean

Gets or sets a value indicating whether the image is used to define an alpha mask of another image.

Returns

boolean

Set Signature

set transparencyMask(value): void

Gets or sets a value indicating whether the image is used to define an alpha mask of another image.

Parameters
value

boolean

Returns

void


whiteIsZero

Get Signature

get whiteIsZero(): boolean

Gets or sets a value specifying whether 0 represents white and 255 represents black (if true) or vice versa (if false).

Returns

boolean

Set Signature

set whiteIsZero(value): void

Gets or sets a value specifying whether 0 represents white and 255 represents black (if true) or vice versa (if false).

Parameters
value

boolean

Returns

void


width

Get Signature

get width(): number

Gets the width of the GrayscaleBitmap, in pixels.

Returns

number

Methods

adjustLevels()

adjustLevels(blackPoint, whitePoint, outputBlack, outputWhite, midtone?): 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).

Parameters

blackPoint

number

The input black point (between 0 and 255).

whitePoint

number

The input white point (between 0 and 255).

outputBlack

number

The output black point (between 0 and 255).

outputWhite

number

The output white point (between 0 and 255).

midtone?

number = 1.0

The value of gamma correction.

Returns

void


applyGaussianBlur()

applyGaussianBlur(radius?, borderMode?, borderColor?): void

Applies a Gaussian blur to this GrayscaleBitmap.

Parameters

radius?

number = 9

The radius of the blur, in pixels.

borderMode?

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

GaussianBlurBorderMode | null

borderColor?

number = 0

The color used to blend with the edge pixels of the image (between 0 and 255).

Returns

void


applyGlow()

applyGlow(infRadius?, blurRadius?): void

When applied to a grayscale mask built from a color image using the Bitmap#toGrayscaleBitmap method, modifies it so that the result can be used as a transparency mask to produce "Glow" or "Soft Edges" effects.

Parameters

infRadius?

number = 4

The radius of inflation (positive, glow) or deflation (negative, soft edges), in pixels.

blurRadius?

number = 6

The radius of Gaussian blur, in pixels.

Returns

void


autoContrast()

Call Signature

autoContrast(): void

Modifies pixel intensities such that available range of values (0..255) is fully covered.

Returns

void

Call Signature

autoContrast(lowClipFraction, highClipFraction): void

Modifies pixel intensities, clipping extremely low and extremely high values, such that available range of values (0..255) is fully covered.

Parameters
lowClipFraction

number

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

highClipFraction

number

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

Returns

void


clear()

clear(value, bounds?): void

Clears the GrayscaleBitmap with the specified value.

Parameters

value

number

The value (between 0 and 255) to fill the image.

bounds?

The target rectangle of the GrayscaleBitmap.

Bounds | null

Returns

void


clip()

clip(bounds, metadataOnly?): GrayscaleBitmap

Creates a new GrayscaleBitmap with a fragment of the image.

Parameters

bounds

Bounds

A clipping rectangle to be extracted as a new GrayscaleBitmap.

metadataOnly?

boolean = false

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

Returns

GrayscaleBitmap

A new instance of the GrayscaleBitmap.


clone()

clone(metadataOnly?): GrayscaleBitmap

Creates a new GrayscaleBitmap with a copy of the image.

Parameters

metadataOnly?

boolean = false

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

Returns

GrayscaleBitmap

A new instance of the GrayscaleBitmap.


free()

free(): void

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

Returns

void

Inherited from

ObjectBase.free


invertColors()

invertColors(): void

Inverts the pixel colors from black to white and vice versa.

Returns

void


rebind()

rebind(omTo): void

Rebinds the object from the current ObjectManager to the specified one.

Parameters

omTo

ObjectManager

The new ObjectManager for the object.

Returns

void

Inherited from

ObjectBase.rebind


toBitmap()

toBitmap(): Bitmap

Creates a Bitmap instance from the current GrayscaleBitmap.

Returns

Bitmap

A new instance of the Bitmap class.


toShadowBitmap()

toShadowBitmap(shadowColor, opacityFactor?, zeroIsOpaque?): Bitmap

Creates a semi-transparent Bitmap from the current GrayscaleBitmap. This method treats the current GrayscaleBitmap as a transparency mask, regardless of the transparencyMask property value.

Parameters

shadowColor

Color

The color to fill opaque pixels of the target bitmap.

opacityFactor?

number = 1

Additional factor to scale the alpha channel.

zeroIsOpaque?

boolean = false

Specifies whether zero values correspond to fully opaque (true) or fully transparent (false) pixels.

Returns

Bitmap

A new instance of the Bitmap class.