toAbgr8888 method
- int pixel
override
Converts a pixel in this
pixel format to the abgr8888 pixel format.
ABGR8888 is used as the canonical integer-based pixel format, and this
method guarantees that all pixel formats can be converted to it. Loss of
precision may occur when this
pixel format has higher precision.
Example
print(abgr8888.toAbgr8888(floatRgba.red)); // 0xFFFF0000
print(abgr8888.toAbgr8888(floatRgba.white)); // 0xFFFFFFFF
Implementation
@override
int toAbgr8888(int pixel) {
// Isolate the least significant 8 bits.
final value = pixel & 0xFF;
// Replicate the value across all channels (R, G, B).
final asRgb = value * 0x010101;
// Set the alpha channel to 0xFF.
return asRgb | 0xFF000000;
}