rgbaToGray static method

Uint8List rgbaToGray(
  1. Uint8List rgba,
  2. int width,
  3. int height,
  4. int stride,
)

Convert an RGBA/BGRA buffer to grayscale.

Implementation

static Uint8List rgbaToGray(
  Uint8List rgba,
  int width,
  int height,
  int stride,
) {
  final input = calloc<Uint8>(rgba.length);
  final out = calloc<Uint8>(width * height);
  try {
    input.asTypedList(rgba.length).setAll(0, rgba);
    _rgbaToGray(input, width, height, stride, out);
    return Uint8List.fromList(out.asTypedList(width * height));
  } finally {
    calloc.free(input);
    calloc.free(out);
  }
}