readPixels

fun readPixels(dst: Bitmap, srcX: Int, srcY: Int): Boolean
fun readPixels(context: DirectContext, dst: Bitmap): Boolean
fun readPixels(context: DirectContext, dst: Bitmap, srcX: Int, srcY: Int): Boolean
fun readPixels(dst: Pixmap, srcX: Int, srcY: Int, cache: Boolean): Boolean


fun readPixels(context: DirectContext?, dst: Bitmap, srcX: Int, srcY: Int, cache: Boolean): Boolean

Copies Rect of pixels from Image to Bitmap. Copy starts at offset (srcX, srcY), and does not exceed Image (getWidth(), getHeight()).

dst specifies width, height, ColorType, AlphaType, and ColorSpace of destination.

Returns true if pixels are copied. Returns false if:

  • dst has no pixels allocated.

Pixels are copied only if pixel conversion is possible. If Image ColorType is ColorType.GRAY_8, or ColorType.ALPHA_8; dst.getColorType() must match. If Image ColorType is ColorType.GRAY_8, dst.getColorSpace() must match. If Image AlphaType is AlphaType.OPAQUE, dst.getAlphaType() must match. If Image ColorSpace is null, dst.getColorSpace() must match. Returns false if pixel conversion is not possible.

srcX and srcY may be negative to copy only top or left of source. Returns false if getWidth() or getHeight() is zero or negative.

Returns false if abs(srcX) >= Image.getWidth(), or if abs(srcY) >= Image.getHeight().

If cache is true, pixels may be retained locally, otherwise pixels are not added to the local cache.

Return

true if pixels are copied to dstPixels

Parameters

context

the DirectContext in play, if it exists

dst

destination bitmap

srcX

column index whose absolute value is less than getWidth()

srcY

row index whose absolute value is less than getHeight()

cache

whether the pixels should be cached locally