public void writeFrame(OutputStream os, Bitmap frame, int delay) throws Exception {
    	// Retrieve image dimension
		int imageWidth = frame.getWidth();
		int imageHeight = frame.getHeight();
		// Determine the logical screen dimension
		if(firstFrame) {
			if(logicalScreenWidth <= 0)
				logicalScreenWidth = imageWidth;
			if(logicalScreenHeight <= 0)
				logicalScreenHeight = imageHeight;
		}
		if(delay <= 0) delay = 100;
		if(imageWidth > logicalScreenWidth) imageWidth = logicalScreenWidth;
		if(imageHeight > logicalScreenHeight) imageHeight = logicalScreenHeight;
		int[] pixels = new int[imageWidth * imageHeight];
		frame.getPixels(pixels, 0, imageWidth, 0, 0, imageWidth, imageHeight);
		writeFrame(pixels, imageWidth, imageHeight, 0, 0, delay, os);
    }
Writes a list of GIFFrame as an animated GIF

@param frames a list of GIFFrame
@param os OutputStream for the animated GIF
@throws Exception
subs/gif-revert/src/main/java/com/engineer/gif/revert/lib/AnimatedGIFWriter.java