uk.co.silentsoftware.core.converters.video
Class GifConverter

java.lang.Object
  extended by uk.co.silentsoftware.core.converters.video.GifConverter

public class GifConverter
extends java.lang.Object

Wrapper around third party GifSequenceWriter class. Note due to that third party API design unlike other converters this converter holds a state and thus must be initialised via (createSequenceWriter) and reset (createGif is intended to be the final call). Note this class is NOT thread safe!


Field Summary
private  java.io.ByteArrayOutputStream baos
          Byte array required to save the created gif
private  GifSequenceWriter writer
          The Gif sequence writer
 
Constructor Summary
GifConverter()
           
 
Method Summary
 void addFrame(java.awt.image.BufferedImage source)
          Adds a single buffered image to the gif being created.
 byte[] createGif()
          Create the gif and clear down afterwards (1 shot method).
 void createSequence(java.awt.image.BufferedImage buf, int gifDisplayTimeMills, boolean loop)
          Create a new gif sequence - note this is not a thread safe method!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

writer

private GifSequenceWriter writer
The Gif sequence writer


baos

private java.io.ByteArrayOutputStream baos
Byte array required to save the created gif

Constructor Detail

GifConverter

public GifConverter()
Method Detail

createGif

public byte[] createGif()
                 throws java.io.IOException
Create the gif and clear down afterwards (1 shot method). Returns null if not initialised.

Returns:
Throws:
java.io.IOException

addFrame

public void addFrame(java.awt.image.BufferedImage source)
              throws java.io.IOException
Adds a single buffered image to the gif being created.

Parameters:
source -
Throws:
java.io.IOException

createSequence

public void createSequence(java.awt.image.BufferedImage buf,
                           int gifDisplayTimeMills,
                           boolean loop)
                    throws javax.imageio.IIOException,
                           java.io.IOException
Create a new gif sequence - note this is not a thread safe method!

Parameters:
gifDisplayTimeMills -
loop -
Throws:
javax.imageio.IIOException
java.io.IOException