RGBLuminanceSource constructor
Implementation
RGBLuminanceSource(this._dataWidth, this._dataHeight, Int32List pixels)
: _left = 0,
_top = 0,
super(_dataWidth, _dataHeight) {
// In order to measure pure decoding speed, we convert the entire image to a greyscale array
// up front, which is the same as the Y channel of the YUVLuminanceSource in the real app.
//
// Total number of pixels suffices, can ignore shape
var size = _dataWidth * _dataHeight;
_luminances = Int8List(size);
for (var offset = 0; offset < size; offset++) {
var pixel = pixels[offset];
var r = (pixel >> 16) & 0xff; // red
var g2 = (pixel >> 7) & 0x1fe; // 2 * green
var b = pixel & 0xff; // blue
// Calculate green-favouring average cheaply
_luminances[offset] = ((r + g2 + b) ~/ 4).toInt();
}
}