map method

Buffer<T> map(
  1. T convert(
    1. T
    )
)

Returns a lazy buffer buffer that converts pixels with the given function.

It is expected that the function does not change the representation of the pixel data, only the values. For example a function that inverts the red channel of an RGB pixel would be acceptable, but a function that converts an RGB pixel to an RGBA pixel would not; for that use mapConvert instead.

Example

final buffer = IntPixels(1, 3, data: Uint32List.fromList([
  abgr8888.red,
  abgr8888.green,
  abgr8888.blue,
]));

// Invert the each pixel.
final converted = buffer.map((pixel) => pixel ^ 0xFFFFFFFF);
print(converted.data); // [0xFF00FFFF, 0xFF00FF00, 0xFF0000FF]

Implementation

Buffer<T> map(T Function(T) convert) {
  return _MapBuffer(this, convert, format);
}