ImageDescriptor.raw constructor Null safety
- ImmutableBuffer buffer,
- {required int width,
- required int height,
- int? rowBytes,
- required PixelFormat pixelFormat}
Creates an image descriptor from raw image pixels.
The pixels
parameter is the pixel data in the encoding described by
format
.
The rowBytes
parameter is the number of bytes consumed by each row of
pixels in the data buffer. If unspecified, it defaults to width
multiplied
by the number of bytes per pixel in the provided format
.
Implementation
// Not async because there's no expensive work to do here.
ImageDescriptor.raw(
ImmutableBuffer buffer, {
required int width,
required int height,
int? rowBytes,
required PixelFormat pixelFormat,
}) {
_width = width;
_height = height;
// We only support 4 byte pixel formats in the PixelFormat enum.
_bytesPerPixel = 4;
_initRaw(this, buffer, width, height, rowBytes ?? -1, pixelFormat.index);
}