TrayIconImageDelegate.fromBytes constructor
TrayIconImageDelegate.fromBytes(
- ByteBuffer pixels
A TrayIconImageDelegate that uses an RGBA image buffer.
The buffer is expected to be in the format of an RGBA image where the size equals TrayIcon.preferredImageSize.
Implementation
TrayIconImageDelegate.fromBytes(ByteBuffer pixels) {
final size = TrayIcon.preferredImageSize;
int x = size.width.toInt();
int y = size.height.toInt();
if (pixels.lengthInBytes != x * y * 4) {
throw ArgumentError(
"The buffer must have $x×$y pixels and 4 bytes per pixel.");
}
setIcon = (id, plugin) =>
plugin.setImageFromPixels(id, x, y, pixels.asInt32List());
}