Float32x4Pixels.from constructor

Float32x4Pixels.from(
  1. Buffer<Float32x4> buffer
)

Creates a copy of the given buffer with the same pixel data and dimensions.

The format and data is copied from the given buffer.

Example

final original = Float32x4Pixels(3, 3);
final clipped = original.getRegion(Rect.fromLTWH(1, 1, 2, 2));

final copy = Float32x4Pixels.from(clipped);
print(copy.width); // 2
print(copy.height); // 2

Implementation

factory Float32x4Pixels.from(Buffer<Float32x4> buffer) {
  final data = Float32x4List(buffer.length);
  data.setAll(0, buffer.data);
  return Float32x4Pixels(
    buffer.width,
    buffer.height,
    data: data,
    format: buffer.format,
  );
}