decode method
Decodes encoded data.
The input is decoded as if by decoder.convert.
Implementation
@override
Image decode(Uint8List encoded, {DecodeOptions? decodeOptions}) {
final DecodeOptions options = decodeOptions ?? rasterDecoder.createDefaultDecodeOptions();
if (options.maxPixels < 1) {
throw RangeError.range(options.maxPixels, 1, null, 'maxPixels');
}
if (!acceptsInput(encoded)) {
final ImageFormat? actualFormat = ImageFormat.sniff(encoded);
throw ImageCodecException('Expected ${format.name} data, found ${actualFormat?.name ?? 'an unknown format'}');
}
try {
return decodeBytes(encoded, decodeOptions: options);
} on ImageCodecException {
rethrow;
} on Object catch (error) {
throw ImageCodecException('Could not decode the ${format.name} image', cause: error);
}
}