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().


pixel data or null



destination width, height, ColorType, AlphaType, ColorSpace


destination row length


column index whose absolute value is less than width()


row index whose absolute value is less than height()