Matrix.fromUint8List constructor

Matrix.fromUint8List(
  1. Uint8List pixels,
  2. int width
)

Creates a Matrix from a Uint8List, typically used for image data.

pixels A Uint8List representing pixel data. width The width of the image.

Implementation

factory Matrix.fromUint8List(
  final Uint8List pixels,
  final int width,
) {
  return Matrix.fromFlatListOfBool(
    [
      for (int i = 0; i < pixels.length; i += 4) pixels[i] == 0,
    ],
    width,
  );
}