addFrame method
This adds the frame passed to image
.
After the last frame has been added, finish is required to be called.
Optional frame duration
is in 1/100 sec.
Implementation
void addFrame(Image image, {int? duration}) {
if (output == null) {
output = OutputBuffer();
_lastColorMap = NeuralQuantizer(image, samplingFactor: samplingFactor);
_lastImage =
ditherPixels(image, _lastColorMap!, dither, ditherSerpentine);
_lastImageDuration = duration;
_width = image.width;
_height = image.height;
return;
}
if (_encodedFrames == 0) {
_writeHeader(_width, _height);
_writeApplicationExt();
}
_writeGraphicsCtrlExt();
_addImage(_lastImage, _width, _height, _lastColorMap!.colorMap, 256);
_encodedFrames++;
_lastColorMap = NeuralQuantizer(image, samplingFactor: samplingFactor);
_lastImage = ditherPixels(image, _lastColorMap!, dither, ditherSerpentine);
_lastImageDuration = duration;
}