decodeImage<Options extends RasterDecodeOptions> function

Image decodeImage<Options extends RasterDecodeOptions>(
  1. Uint8List bytes, {
  2. Options? options,
})

Decodes a supported image synchronously to straight RGBA.

When supplied, options must match the format detected from bytes.

Implementation

Image decodeImage<Options extends RasterDecodeOptions>(
  Uint8List bytes, {
  Options? options,
}) {
  final ImageFormat? format = ImageFormat.sniff(bytes);
  if (format == null) {
    throw const ImageCodecException('The encoded image format is not supported');
  }
  return ImageCodecRegistry.require(format).decode(
    bytes,
    decodeOptions: options,
  );
}