mapConvert<R> method
- PixelFormat<
R, void> format
Returns a lazy buffer that converts pixels to the given format
.
If this.format == format
, the buffer is returned as-is.
Example
final buffer = Float32x4Pixels(1, 3, data: Float32x4List.fromList([
floatRgba.red,
floatRgba.green,
floatRgba.blue,
]));
final converted = buffer.mapConvert(abgr8888);
print(converted.data); // [0xFFFF0000, 0xFF00FF00, 0xFF0000FF]
Implementation
Buffer<R> mapConvert<R>(PixelFormat<R, void> format) {
if (format == this.format) {
return this as Buffer<R>;
}
return _MapBuffer(
this,
(p) => format.convert(p, from: this.format),
format,
);
}