ImageDescriptor.raw constructor Null safety

  1. ImmutableBuffer buffer,
  2. {required int width,
  3. required int height,
  4. int? rowBytes,
  5. 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.


// Not async because there's no expensive work to do here.
  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);