# Bitmap

## Content

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

***

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

# Class: Bitmap

Represents an uncompressed in-memory bitmap.

## Extends

- [`ObjectBase`](ObjectBase)

## Constructors

### Constructor

> **new Bitmap**(`width`, `height`, `backColor?`): `Bitmap`

Creates a Bitmap instance with optionally initialized pixels.

#### Parameters

##### width

`number`

The bitmap width, in pixels.

##### height

`number`

The bitmap height, in pixels.

##### backColor?

The optional background color to fill the Bitmap.

[`Color`](../type-aliases/Color) | `null`

#### Returns

`Bitmap`

#### Overrides

`ObjectBase.constructor`

### Constructor

> **new Bitmap**(`om`, `width`, `height`, `backColor?`): `Bitmap`

Creates a Bitmap instance with optionally initialized pixels.

#### Parameters

##### om

[`ObjectManager`](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.

##### backColor?

The optional background color to fill the Bitmap.

[`Color`](../type-aliases/Color) | `null`

#### Returns

`Bitmap`

#### Overrides

`ObjectBase.constructor`

## Accessors

### blackAndWhite

#### Get Signature

> **get** **blackAndWhite**(): `boolean`

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

##### Returns

`boolean`

***

### context

#### Get Signature

> **get** **context**(): [`BmpContext`](BmpContext)

Gets the current [BmpContext](BmpContext) for this Bitmap.

##### Returns

[`BmpContext`](BmpContext)

***

### grayscale

#### Get Signature

> **get** **grayscale**(): `boolean`

Determines whether the image contains only opaque grayscale pixels.

##### Returns

`boolean`

***

### height

#### Get Signature

> **get** **height**(): `number`

Gets the height of the bitmap, 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)

***

### width

#### Get Signature

> **get** **width**(): `number`

Gets the width of the bitmap, in pixels.

##### Returns

`number`

## Methods

### addGlow()

> **addGlow**(`glowColor`, `glowOpacity?`, `inflationRadius?`, `gaussianBlurRadius?`): `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.

#### Parameters

##### glowColor

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

The glow color.

##### glowOpacity?

`number` = `0.8`

The glow opacity, between 0 and 1.

##### inflationRadius?

`number` = `6`

The glow inflation radius, in pixels.

##### gaussianBlurRadius?

`number` = `9`

The Gaussian blur radius, in pixels.

#### Returns

`Bitmap`

A new Bitmap with glow effect.

***

### addShadow()

> **addShadow**(`xOffset`, `yOffset`, `shadowColor`, `shadowOpacity?`, `gaussianBlurRadius?`): `Bitmap`

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

The shadow color.

##### shadowOpacity?

`number` = `0.6`

The shadow opacity, between 0 and 1.

##### gaussianBlurRadius?

`number` = `9`

The shadow blur radius, in pixels.

#### Returns

`Bitmap`

A new Bitmap with shadow.

***

### 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

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

The input black point color.

##### whitePoint

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

The input white point color.

##### outputBlack

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

The output black point color.

##### outputWhite

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

The output white point color.

##### midtone?

`number` = `1.0`

The value of gamma correction.

#### Returns

`void`

***

### alphaBlend()

> **alphaBlend**(`srcBitmap`, `dstX`, `dstY`, `options?`): `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.

##### options?

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

The alpha blend options.

#### Returns

`void`

***

### applyBilevelTransparencyMask()

> **applyBilevelTransparencyMask**(`mask`, `bounds?`): `void`

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

#### Parameters

##### mask

[`BilevelBitmap`](BilevelBitmap)

A [BilevelBitmap](BilevelBitmap) with the transparency mask.

##### bounds?

The target rectangle of the bitmap.

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

#### Returns

`void`

***

### applyBradleyThresholdingEffect()

> **applyBradleyThresholdingEffect**(`sDivider?`, `t?`, `bounds?`): `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

##### sDivider?

`number` = `8`

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

##### t?

`number` = `15`

The value of t parameter.

##### bounds?

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

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

#### Returns

`void`

***

### applyBrightnessContrast()

> **applyBrightnessContrast**(`brightness`, `contrast`, `bounds?`): `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.

##### bounds?

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

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

#### Returns

`void`

***

### applyDitheringEffect()

> **applyDitheringEffect**(`ditheringMethod?`, `bounds?`): `void`

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

#### Parameters

##### ditheringMethod?

[`DitheringMethod`](../enumerations/DitheringMethod)

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

##### bounds?

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

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

#### Returns

`void`

***

### applyGammaCorrection()

> **applyGammaCorrection**(`gamma?`, `bounds?`): `void`

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

#### Parameters

##### gamma?

`number` = `2.2`

A value of Gamma, from 0.001 to 1000.

##### bounds?

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

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

#### Returns

`void`

***

### applyGaussianBlur()

> **applyGaussianBlur**(`radius?`, `borderMode?`, `borderColor?`, `bounds?`): `void`

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

#### 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?

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

[`Color`](../type-aliases/Color) | `null`

##### bounds?

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

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

#### Returns

`void`

***

### applyGrayscaleEffect()

> **applyGrayscaleEffect**(`standard?`, `bounds?`): `void`

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

#### Parameters

##### standard?

[`GrayscaleStandard`](../enumerations/GrayscaleStandard)

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

##### bounds?

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

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

#### Returns

`void`

***

### applyGrayscaleTransparencyMask()

> **applyGrayscaleTransparencyMask**(`mask`, `bounds?`): `void`

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

#### Parameters

##### mask

[`GrayscaleBitmap`](GrayscaleBitmap)

A [GrayscaleBitmap](GrayscaleBitmap) with the transparency mask.

##### bounds?

The target rectangle of the bitmap.

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

#### Returns

`void`

***

### applyHueRotation()

> **applyHueRotation**(`angleInDegrees`, `bounds?`): `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.

##### bounds?

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

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

#### Returns

`void`

***

### applyLuminanceToAlpha()

> **applyLuminanceToAlpha**(`bounds?`): `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

##### bounds?

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

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

#### Returns

`void`

***

### applyOpacityEffect()

> **applyOpacityEffect**(`opacity`, `bounds?`): `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.

##### bounds?

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

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

#### Returns

`void`

***

### applyOtsuThresholdingEffect()

> **applyOtsuThresholdingEffect**(`bounds?`): `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

##### bounds?

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

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

#### Returns

`void`

***

### applySaturationEffect()

> **applySaturationEffect**(`saturation`, `bounds?`): `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).

##### bounds?

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

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

#### Returns

`void`

***

### applySepiaEffect()

> **applySepiaEffect**(`bounds?`): `void`

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

#### Parameters

##### bounds?

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

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

#### Returns

`void`

***

### applySoftEdges()

> **applySoftEdges**(`inflationRadius?`, `gaussianBlurRadius?`): `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

##### inflationRadius?

`number` = `-6`

The negative radius of inflation, in pixels.

##### gaussianBlurRadius?

`number` = `9`

The Gaussian blur radius, in pixels.

#### Returns

`void`

***

### applyTemperatureAndTint()

> **applyTemperatureAndTint**(`temperature`, `tint`, `bounds?`): `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.

##### bounds?

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

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

#### Returns

`void`

***

### autoLevels()

> **autoLevels**(`keepRelativeIntensities?`, `lowClipFraction?`, `highClipFraction?`): `void`

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

#### Parameters

##### keepRelativeIntensities?

`boolean` = `true`

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

##### lowClipFraction?

`number` = `0.002`

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

##### highClipFraction?

`number` = `0.002`

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

#### Returns

`void`

***

### bitBlt()

> **bitBlt**(`srcBitmap`, `dstX`, `dstY`, `options?`): `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.

##### options?

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

The source coordinates, size, and other options.

#### Returns

`void`

***

### clear()

> **clear**(`color`, `bounds?`): `void`

Clears the whole Bitmap or its part with specified color.

#### Parameters

##### color

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

The color to fill the image.

##### bounds?

The target rectangle of the Bitmap.

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

#### Returns

`void`

***

### clip()

#### Call Signature

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

Creates a new Bitmap 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

`Bitmap`

A new Bitmap with a fragment of the source image.

#### Call Signature

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

Creates a new Bitmap with a fragment of the image.

##### Parameters

###### bounds

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

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

###### metadataOnly?

`boolean`

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

##### Returns

`Bitmap`

A new Bitmap with a fragment of the source image.

***

### clone()

> **clone**(`metadataOnly?`): `Bitmap`

Creates a new Bitmap with a copy of the image.

#### Parameters

##### metadataOnly?

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

***

### compositeAndBlend()

> **compositeAndBlend**(`srcBitmap`, `dstX`, `dstY`, `options?`): `void`

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.

##### options?

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

The compositing and blending options.

#### Returns

`void`

***

### convertToOpaque()

> **convertToOpaque**(`backColor`, `bounds?`): `void`

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

#### Parameters

##### backColor

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

The color to be used as background for transparent pixels.

##### bounds?

The target rectangle of the bitmap.

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

#### Returns

`void`

***

### exportColorChannel()

> **exportColorChannel**(`destination`, `colorChannel`): `void`

Copies data from one color channel of the current Bitmap to an existing [GrayscaleBitmap](GrayscaleBitmap) of the same pixel size.

#### Parameters

##### destination

[`GrayscaleBitmap`](GrayscaleBitmap)

The target [GrayscaleBitmap](GrayscaleBitmap).

##### colorChannel

[`ColorChannel`](../enumerations/ColorChannel)

A channel of the source Bitmap to be exported.

#### Returns

`void`

***

### flipRotate()

> **flipRotate**(`action`, `clipBounds?`): `Bitmap`

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

#### Parameters

##### action

[`FlipRotateAction`](../enumerations/FlipRotateAction)

The operation to be applied.

##### clipBounds?

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

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

#### Returns

`Bitmap`

A new Bitmap with transformed image.

***

### 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)

***

### getContentRect()

> **getContentRect**(`backColor`): [`Rect`](../type-aliases/Rect) \| `null`

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

#### Parameters

##### backColor

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

The background color.

#### Returns

[`Rect`](../type-aliases/Rect) \| `null`

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

***

### hasTransparentPixels()

> **hasTransparentPixels**(`bounds?`): `boolean`

Determines whether the image contains transparent or semitransparent pixels.

#### Parameters

##### bounds?

The source rectangle to analyse.

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

#### Returns

`boolean`

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

***

### importColorChannel()

> **importColorChannel**(`source`, `colorChannel`): `void`

Copies data from a [GrayscaleBitmap](GrayscaleBitmap) to one color channel of the current Bitmap of the same pixel size.

#### Parameters

##### source

[`GrayscaleBitmap`](GrayscaleBitmap)

A [GrayscaleBitmap](GrayscaleBitmap) with source data.

##### colorChannel

[`ColorChannel`](../enumerations/ColorChannel)

A channel of the destination Bitmap to be updated.

#### Returns

`void`

***

### newContext()

> **newContext**(`bmpContextProperties?`): [`BmpContext`](BmpContext)

Creates a [BmpContext](BmpContext) for the current Bitmap and optionally fills it with a background color.

#### Parameters

##### bmpContextProperties?

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

The settings for creating a [DrawingContext](DrawingContext) for Bitmap.

#### Returns

[`BmpContext`](BmpContext)

An instance of BmpContext.

***

### 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)

***

### resize()

#### Call Signature

> **resize**(`width`, `height`, `interpolationMode?`): `Bitmap`

Creates a new Bitmap with a resized image fragment.
The source Bitmap remains unchanged.

##### Parameters

###### width

`number`

The width of the resized image, in pixels.

###### height

`number`

The height of the resized image, in pixels.

###### interpolationMode?

[`InterpolationMode`](../enumerations/InterpolationMode)

The interpolation mode to use when scaling. The default is Linear.

##### Returns

`Bitmap`

A new Bitmap with resized image.

#### Call Signature

> **resize**(`options`): `Bitmap`

Creates a new Bitmap with a resized image fragment.
The source Bitmap remains unchanged.

##### Parameters

###### options

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

The resizing options.

##### Returns

`Bitmap`

A new Bitmap with resized image.

***

### saveAsJpeg()

> **saveAsJpeg**(`quality?`): `Uint8Array`

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

#### Parameters

##### quality?

`number` = `90`

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

#### Returns

`Uint8Array`

A byte array with JPEG-encoded image data.

***

### saveAsJpegImage()

> **saveAsJpegImage**(`quality?`): [`Image`](Image)

Saves the Bitmap as a JPEG-encoded Image.

#### Parameters

##### quality?

`number` = `90`

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

#### Returns

[`Image`](Image)

The resulting Image object.

***

### saveAsPng()

> **saveAsPng**(`fastest?`): `Uint8Array`

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

#### Parameters

##### fastest?

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

***

### saveAsPngImage()

> **saveAsPngImage**(`fastest?`): [`Image`](Image)

Saves the Bitmap as a PNG-encoded Image.

#### Parameters

##### fastest?

`boolean` = `false`

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

#### Returns

[`Image`](Image)

The resulting Image object.

***

### toBilevelBitmap()

> **toBilevelBitmap**(`colorChannel?`, `lowerBitsFirst?`, `whiteIsZero?`): [`BilevelBitmap`](BilevelBitmap)

Creates a [BilevelBitmap](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](BilevelBitmap) class.

#### Parameters

##### colorChannel?

[`ColorChannel`](../enumerations/ColorChannel)

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

##### lowerBitsFirst?

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

##### whiteIsZero?

`boolean` = `false`

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

#### Returns

[`BilevelBitmap`](BilevelBitmap)

A new instance of [BilevelBitmap](BilevelBitmap).

***

### toGrayscaleBitmap()

> **toGrayscaleBitmap**(`colorChannel?`, `whiteIsZero?`): [`GrayscaleBitmap`](GrayscaleBitmap)

Creates a [GrayscaleBitmap](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](#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

##### colorChannel?

[`ColorChannel`](../enumerations/ColorChannel)

The color channel used as the source of grayscale data.

##### whiteIsZero?

`boolean` = `false`

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

#### Returns

[`GrayscaleBitmap`](GrayscaleBitmap)

A new instance of [GrayscaleBitmap](GrayscaleBitmap).
