// Create the actual Image for output
// Pass old image through grayscale filter, creating new image
// This is necessary since GIFs are limited to 255 colors.
// The easiest way to guarantee this is to convert to greyscale.
Image oldImage = createOutputImage();
ImageFilter filter = new GreyscaleFilter();
Image newImage = createImage(new FilteredImageSource(oldImage.getSource(), filter));
// Use MediaTracker to wait for new image to be created
try {
MediaTracker tracker = new MediaTracker(this);