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. They are packed in bytes in the
order described by pixelFormat
, then grouped in rows, from left to right,
then top to bottom.
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);
}