getRow method

  1. @override
Uint8List getRow(
  1. int y,
  2. Uint8List? row
)
override

Fetches one row of luminance data from the underlying platform's bitmap. Values range from 0 (black) to 255 (white). Because Java does not have an unsigned byte type, callers will have to bitwise and with 0xff for each value. It is preferable for implementations of this method to only fetch this row rather than the whole image, since no 2D Readers may be installed and matrix may never be called.

@param y The row to fetch, which must be in [0,getHeight()) @param row An optional preallocated array. If null or too small, it will be ignored. Always use the returned object, and ignore the .length of the array. @return An array containing the luminance data.

Implementation

@override
Uint8List getRow(int y, Uint8List? row) {
  if (y < 0 || y >= height) {
    throw ArgumentError('Requested row is outside the image: $y');
  }
  if (row == null || row.length < width) {
    row = Uint8List(width);
  }
  final offset = (y + _top) * _dataWidth + _left;
  List.copyRange(row, 0, _luminances, offset, offset + width);
  return row;
}