imageCreateFromRgba method
Creates a native image by copying an RGBA pixel buffer.
Implementation
({int status, TerminalImageHandle? handle}) imageCreateFromRgba(
Uint8List pixels, {
required int width,
required int height,
required int stride,
}) {
for (final (name, value) in <(String, int)>[
('width', width),
('height', height),
('stride', stride),
]) {
_checkUnsignedAbi(value, 0xFFFFFFFF, name);
}
return _guardAlloc('Failed to create RGBA image', (allocator) {
final bytes = _copyBytes(allocator, pixels);
final output = allocator<Uint32>()..value = 0;
final status = _native.imageCreateFromRgba(
bytes,
pixels.length,
width,
height,
stride,
output,
);
final value = output.value;
return (
status: status,
handle: value == 0 ? null : TerminalImageHandle.fromNative(value),
);
});
}