convertBGRA8888 function

void convertBGRA8888(
  1. List<Plane> planes,
  2. NativeDataStruct data
)

Converts BGRA8888 to BGR888 format (removing the alpha channel), the result can be passed to VideoWorker.

Implementation

void convertBGRA8888(List<Plane> planes, NativeDataStruct data) {
  final plane = planes[0];
  int totalBytes = (plane.bytes.length / 4 * 3).toInt();

  if (data.size != totalBytes) data.resize(totalBytes);

  int byteOffset = 0;
  for (int i = 0; i < plane.bytes.length; i += 4) {
    data.bytes![byteOffset + 0] = plane.bytes[i + 0];
    data.bytes![byteOffset + 1] = plane.bytes[i + 1];
    data.bytes![byteOffset + 2] = plane.bytes[i + 2];
    byteOffset += 3;
  }
}