# GrayscaleBitmap

## Content

[**DsPdfJS API v9.1.3**](../README)

***

[DsPdfJS API](../globals) / GrayscaleBitmap

# Class: GrayscaleBitmap

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

## Extends

- [`ObjectBase`](ObjectBase)

## 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`](../type-aliases/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`](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`](../type-aliases/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`](ObjectBase).[`id`](ObjectBase#id)

***

### om

#### Get Signature

> **get** **om**(): [`ObjectManager`](ObjectManager)

Gets the owner [ObjectManager](ObjectManager) instance.

##### Returns

[`ObjectManager`](ObjectManager)

#### Inherited from

[`ObjectBase`](ObjectBase).[`om`](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`](../enumerations/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](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`](../type-aliases/Bounds) | `null`

#### Returns

`void`

***

### clip()

#### Call Signature

> **clip**(`x`, `y`, `width`, `height`, `metadataOnly?`): `GrayscaleBitmap`

Creates a new GrayscaleBitmap with a fragment of the image.

##### Parameters

###### x

`number`

The X coordinate of the clipping rectangle.

###### y

`number`

The Y coordinate of the clipping rectangle.

###### width

`number`

The width of the clipping rectangle.

###### height

`number`

The height of the clipping rectangle.

###### metadataOnly?

`boolean`

Specifies whether to copy the image metadata only, not actual pixel data. The default is false.

##### Returns

`GrayscaleBitmap`

A new GrayscaleBitmap with a fragment of the source image.

#### Call Signature

> **clip**(`bounds`, `metadataOnly?`): `GrayscaleBitmap`

Creates a new GrayscaleBitmap with a fragment of the image.

##### Parameters

###### bounds

[`Bounds`](../type-aliases/Bounds)

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

###### metadataOnly?

`boolean`

Specifies whether to copy the image metadata only, not actual pixel data. The default is false.

##### Returns

`GrayscaleBitmap`

A new GrayscaleBitmap with a fragment of the source image.

***

### 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](ObjectManager) and deallocates its memory, if possible.

#### Returns

`void`

#### Inherited from

[`ObjectBase`](ObjectBase).[`free`](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](ObjectManager) to the specified one.

#### Parameters

##### omTo

[`ObjectManager`](ObjectManager)

The new [ObjectManager](ObjectManager) for the object.

#### Returns

`void`

#### Inherited from

[`ObjectBase`](ObjectBase).[`rebind`](ObjectBase#rebind)

***

### toBitmap()

> **toBitmap**(): [`Bitmap`](Bitmap)

Creates a [Bitmap](Bitmap) instance from the current GrayscaleBitmap.

#### Returns

[`Bitmap`](Bitmap)

A new instance of the [Bitmap](Bitmap) class.

***

### toShadowBitmap()

> **toShadowBitmap**(`shadowColor`, `opacityFactor?`, `zeroIsOpaque?`): [`Bitmap`](Bitmap)

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

#### Parameters

##### shadowColor

[`Color`](../type-aliases/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`](Bitmap)

A new instance of the [Bitmap](Bitmap) class.
