Skip to main content
createImageBitmap - Canvas - Web documentation
function createImageBitmap
createImageBitmap(): Promise<ImageBitmap>

Create a new ImageBitmap object from a given source.

Parameters

The image to create an ImageBitmap from.

optional
options: ImageBitmapOptions

The options for creating the ImageBitmap.

Return Type

Promise<ImageBitmap>
createImageBitmap(
sx: number,
sy: number,
sw: number,
sh: number,
): Promise<ImageBitmap>

Create a new ImageBitmap object from a given source, cropping to the specified rectangle.

Parameters

The image to create an ImageBitmap from.

sx: number

The x coordinate of the top-left corner of the sub-rectangle from which the ImageBitmap will be cropped.

sy: number

The y coordinate of the top-left corner of the sub-rectangle from which the ImageBitmap will be cropped.

sw: number

The width of the sub-rectangle from which the ImageBitmap will be cropped.

sh: number

The height of the sub-rectangle from which the ImageBitmap will be cropped.

optional
options: ImageBitmapOptions

The options for creating the ImageBitmap.

Return Type

Promise<ImageBitmap>