decode method
Decode the file and extract a single image from it. If the file is
animated, the specified frame
will be decoded. If there was a problem
decoding the file, null is returned.
Implementation
@override
Image? decode(Uint8List bytes, {int? frame}) {
_input = InputBuffer(bytes);
info = _readHeader(_input);
if (info == null) {
return null;
}
final len = numFrames();
if (len == 1 || frame != 0) {
return decodeFrame(frame ?? 0);
}
final image = decodeFrame(0);
if (image == null) {
return null;
}
image
..exif = ExifData.fromInputBuffer(InputBuffer(bytes))
..frameType = FrameType.page;
for (var i = 1; i < len; ++i) {
final frame = decodeFrame(i);
image.addFrame(frame);
}
return image;
}