readPixels

fun readPixels(pixmap: Pixmap?, srcX: Int, srcY: Int): Boolean


fun readPixels(bitmap: Bitmap?, srcX: Int, srcY: Int): Boolean

Copies Rect of pixels from Surface into bitmap.

Source Rect corners are (srcX, srcY) and Surface (width(), height()). Destination Rect corners are (0, 0) and (bitmap.width(), bitmap.height()). Copies each readable pixel intersecting both rectangles, without scaling, converting to bitmap.colorType() and bitmap.alphaType() if required.

Pixels are readable when Surface is raster, or backed by a GPU.

The destination pixel storage must be allocated by the caller.

Pixel values are converted only if ColorType and AlphaType do not match. Only pixels within both source and destination rectangles are copied. dst contents outside Rect intersection are unchanged.

Pass negative values for srcX or srcY to offset pixels across or down destination.

Does not copy, and returns false if:

  • Source and destination rectangles do not intersect.

  • Surface pixels could not be converted to dst.colorType() or dst.alphaType().

  • dst pixels could not be allocated.

  • dst.rowBytes() is too small to contain one row of pixels.

Return

true if pixels were copied

Parameters

bitmap

storage for pixels copied from SkSurface

srcX

offset into readable pixels on x-axis; may be negative

srcY

offset into readable pixels on y-axis; may be negative

See also