grayToRgba static method
Packs a grayscale buffer into ARGB pixels, ready for decodeImageFromPixels.
Implementation
static Uint8List grayToRgba(UGrayImage image) {
final Uint8List out = Uint8List(image.width * image.height * 4);
for (int y = 0; y < image.height; y++) {
final int source = y * image.stride;
final int destination = y * image.width * 4;
for (int x = 0; x < image.width; x++) {
final int value = image.data[source + x];
out[destination + x * 4] = value;
out[destination + x * 4 + 1] = value;
out[destination + x * 4 + 2] = value;
out[destination + x * 4 + 3] = 255;
}
}
return out;
}