convert method
override
Converts input
and returns the result of the conversion.
Implementation
@override
Uint32List convert(Buffer<int> input) {
final width = input.width;
final height = input.height;
final data = input.data;
// Convert every 32 pixels into 32-bits.
// That is, a 128x128 bitmap is represented as 4x4 32-bit words.
final output = Uint32List(2 + (data.length ~/ 32));
output[0] = width;
output[1] = height;
var word = 0;
var bit = 0;
var offset = 2;
for (final pixel in input.data) {
if (pixel != input.format.zero) {
word |= 1 << bit;
}
bit++;
if (bit == 32) {
output[offset] = word;
word = 0;
bit = 0;
offset++;
}
}
return output;
}