public void write(OutputStream output) throws IOException {
BitUtils.writeString(output, "GIF87a");
ScreenDescriptor sd = new ScreenDescriptor(this.imageWidth, this.imageHeight, this.numberOfColors);
sd.write(output);
output.write(this.allColors, 0, this.allColors.length);
ImageDescriptor id = new ImageDescriptor(this.imageWidth, this.imageHeight, ',');
id.write(output);
byte codesize = BitUtils.BitsNeeded(this.numberOfColors);
if (codesize == 1)
codesize++;
output.write(codesize);
LZWCompressor.LZWCompress(output, codesize, this.allPixels);
output.write(0);
id = new ImageDescriptor((byte) 0, (byte) 0, ';');
id.write(output);
output.flush();
}