decodeFrame method
Decode a single frame from the data that was set with startDecode.
If frame
is out of the range of available frames, null is returned.
Non animated image files will only have frame
0. An Image
is returned, which provides the image, and top-left coordinates of the
image, as animated frames may only occupy a subset of the canvas.
Implementation
@override
Image? decodeFrame(int frame) {
if (input == null) {
return null;
}
final jpeg = JpegData();
jpeg.read(input!.buffer);
if (jpeg.frames.length != 1) {
throw ImageException('only single frame JPEGs supported');
}
return jpeg.getImage();
}