public void writeFrame(OutputStream os, GIFFrame frame) throws Exception {
    	// Retrieve image dimension
    	Bitmap image = frame.getFrame();
    	int imageWidth = image.getWidth();
		int imageHeight = image.getHeight();
		int frameLeft = frame.getLeftPosition();
		int frameTop = frame.getTopPosition();
		// Determine the logical screen dimension
		if(firstFrame) {
			if(logicalScreenWidth <= 0)
				logicalScreenWidth = imageWidth;
			if(logicalScreenHeight <= 0)
				logicalScreenHeight = imageHeight;
		}
		if(frameLeft >= logicalScreenWidth || frameTop >= logicalScreenHeight) return;
		if((frameLeft + imageWidth) > logicalScreenWidth) imageWidth = logicalScreenWidth - frameLeft;
		if((frameTop + imageHeight) > logicalScreenHeight) imageHeight = logicalScreenHeight - frameTop;
		int[] pixels = new int[imageWidth * imageHeight];
		image.getPixels(pixels, 0, imageWidth, 0, 0, imageWidth, imageHeight);
		// Handle transparency color if explicitly set
    	if(frame.getTransparencyFlag() == GIFFrame.TRANSPARENCY_INDEX_SET && frame.getTransparentColor() != -1) {
			int transColor = (frame.getTransparentColor() & 0x00ffffff);				
			for(int j = pixels.length - 1; j > 0; j--) {
				int pixel = (pixels[j] & 0x00ffffff);
				if(pixel == transColor) pixels[j] = pixel; 
			}
		}    	
		writeFrame(pixels, imageWidth, imageHeight, frame.getLeftPosition(), frame.getTopPosition(),
				frame.getDelay(), frame.getDisposalMethod(), frame.getUserInputFlag(), 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