public bool AddFrame(Image im)
{
if ((im == null) || !_started)
return false;
bool ok = true;
try {
if (!_sizeSet)
// use first frame's size
SetSize(im.Width, im.Height);
_image = im;
GetImagePixels(); // convert to correct format if necessary
AnalyzePixels(); // build color table & map pixels
if (_firstFrame) {
WriteLSD(); // logical screen descriptior
WritePalette(); // global color table
if (_repeat >= 0)
// use NS app extension to indicate reps
WriteNetscapeExt();
}
WriteGraphicCtrlExt(); // write graphic control extension
WriteImageDesc(); // image descriptor
if (!_firstFrame)
WritePalette(); // local color table
WritePixels(); // encode and write pixel data
_firstFrame = false;
} catch (IOException) {
ok = false;
}
return ok;
}