<div class='type'>Function</div>


<a id='references'></a>


<h2 id="topixelmap-startx-starty-width-height-buffer-bufferoffset-stride">toPixelMap</h2>

<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun ImageBitmap.toPixelMap(
    startX: Int = 0,
    startY: Int = 0,
    width: Int = this.width,
    height: Int = this.height,
    buffer: IntArray = IntArray(width * height),
    bufferOffset: Int = 0,
    stride: Int = width,
): PixelMap
```


Convenience method to extract pixel information from the given ImageBitmap into a `PixelMap` that
supports for querying pixel information based on

Note this method can block so it is recommended to not invoke this method in performance critical
code paths

#### Parameters

| | |
| --- | --- |
| startX | The x-coordinate of the first pixel to read from the `ImageBitmap` |
| startY | The y-coordinate of the first pixel to read from the `ImageBitmap` |
| width | The number of pixels to read from each row |
| height | The number of rows to read |
| buffer | The array to store the `ImageBitmap`'s colors. By default this allocates an `IntArray` large enough to store all the pixel information. Consumers of this API are advised to use the smallest `IntArray` necessary to extract relevant pixel information |
| bufferOffset | The first index to write into the buffer array, this defaults to 0 |
| stride | The number of entries in `buffer` to skip between rows (must be >= `width` |