decodeImage<Options extends RasterDecodeOptions> function
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,
);
}