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();
if (!image.hasPalette) {
if (quantizerType == QuantizerType.neural) {
_lastColorMap = NeuralQuantizer(image,
numberOfColors: numColors, samplingFactor: samplingFactor);
} else {
_lastColorMap = OctreeQuantizer(image, numberOfColors: numColors);
}
_lastImage = ditherImage(image,
quantizer: _lastColorMap!,
kernel: dither,
serpentine: ditherSerpentine);
} else {
_lastImage = image;
}
_lastImageDuration = duration;
_width = image.width;
_height = image.height;
return;
}
if (_encodedFrames == 0) {
_writeHeader(_width, _height);
_writeApplicationExt();
}
_writeGraphicsCtrlExt(_lastImage!);
_addImage(_lastImage!, _width, _height);
_encodedFrames++;
if (!image.hasPalette) {
if (quantizerType == QuantizerType.neural) {
_lastColorMap = NeuralQuantizer(image,
numberOfColors: numColors, samplingFactor: samplingFactor);
} else {
_lastColorMap = OctreeQuantizer(image, numberOfColors: numColors);
}
_lastImage = ditherImage(image,
quantizer: _lastColorMap!,
kernel: dither,
serpentine: ditherSerpentine);
} else {
_lastImage = image;
}
_lastImageDuration = duration;
}