readPixels

fun readPixels(dstInfo: ImageInfo = imageInfo, dstRowBytes: Int = rowBytes, srcX: Int = 0, srcY: Int = 0): ByteArray?

Copies a rect of pixels from Bitmap. Copy starts at (srcX, srcY), and does not exceed Bitmap (getWidth(), getHeight()).

dstInfo specifies width, height, ColorType, AlphaType, and ColorSpace of destination. dstRowBytes specifics the gap from one destination row to the next. Returns true if pixels are copied. Returns false if:

  • dstRowBytes is less than dstInfo.getMinRowBytes()

  • PixelRef is null

Pixels are copied only if pixel conversion is possible. If Bitmap getColorType() is ColorType.GRAY_8, or ColorType.ALPHA_8; dstInfo.colorType() must match. If Bitmap getClorType() is ColorType.GRAY_8, dstInfo.getColorSpace() must match. If Bitmap getAlphaType() is ColorAlphaType.OPAQUE, dstInfo.getAlphaType() must match. If Bitmap getColorSpace() is null, dstInfo.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) >= getWidth(), or if abs(srcY) >= getHeight().

Return

pixel data or null

Parameters

dstInfo

destination width, height, ColorType, AlphaType, ColorSpace

dstRowBytes

destination row length

srcX

column index whose absolute value is less than width()

srcY

row index whose absolute value is less than height()