com.gif4j.light
Class GifFrame

java.lang.Object
  extended bycom.gif4j.light.GifFrame

public class GifFrame
extends java.lang.Object

An instance of this class is used as a container to aggregate and encode the gif format specific information about a single image frame. This information includes:

  • Image Data (bitmap) - is represented by Image instance
  • Frame Position - indicates the position inside the GifImage logical screen. This position can be set absolutely by Point instance or relatively by layout constraint (see LAYOUT_TOP_LEFT etc).
  • Disposal Method - indicates the way in which the graphic is to be treated after being displayed. (see DISPOSAL_METHOD_NOT_SPECIFIED, DISPOSAL_METHOD_DO_NOT_DISPOSE, DISPOSAL_METHOD_RESTORE_TO_PREVIOUS, DISPOSAL_METHOD_RESTORE_TO_BACKGROUND_COLOR )
  • Delay Time - If not 0, this field specifies the number of hundredths (1/100) of a second to wait before continuing with the processing of the Data Stream. The clock starts ticking immediately after the graphic is rendered. This field may be used in conjunction with the User Input Flag field.
  • Local Color Table (OPTIONAL see information about Global Color Table GifImage) - This block contains a color table, which is a sequence of bytes representing red-green-blue color triplets. The Local Color Table is used by the image that immediately follows. If present, this color table temporarily becomes the active color table and the following image should be processed using it. One color from this table can be marked as transparent.
  • Version:
    1.0
    Author:
    Gif4J Software - Java GIF image processing solutions
    See Also:
    GifImage, Image, ColorModel, IndexColorModel

    Field Summary
    static int DISPOSAL_METHOD_DO_NOT_DISPOSE
              Do not dispose.
    static int DISPOSAL_METHOD_NOT_SPECIFIED
              No disposal specified.
    static int DISPOSAL_METHOD_RESTORE_TO_BACKGROUND_COLOR
              Restore to background color.
    static int DISPOSAL_METHOD_RESTORE_TO_PREVIOUS
              Restore to previous.
    static int LAYOUT_BOTTOM_CENTER
              The bottom-center layout constraint.
    static int LAYOUT_BOTTOM_LEFT
              The bottom-left layout constraint.
    static int LAYOUT_BOTTOM_RIGHT
              The bottom-right layout constraint.
    static int LAYOUT_MIDDLE_CENTER
              The middle-center layout constraint.
    static int LAYOUT_MIDDLE_LEFT
              The middle-left layout constraint.
    static int LAYOUT_MIDDLE_RIGHT
              The middle-right layout constraint.
    static int LAYOUT_TOP_CENTER
              The top-center layout constraint
    static int LAYOUT_TOP_LEFT
              The top-left layout constraint.
    static int LAYOUT_TOP_RIGHT
              The top-right layout constraint.
     
    Constructor Summary
    GifFrame(java.awt.Image image)
              Constructs GifFrame from the specified Image with the absolute position (0,0), indefinite delay and DISPOSAL_METHOD_DO_NOT_DISPOSE disposal method.
    GifFrame(java.awt.Image image, int layoutConstraint)
              Constructs GifFrame from the specified Image with the relative position (final position is calculated according to one of the predifined layout constraint before the final encoding process starts), indefinite delay and DISPOSAL_METHOD_DO_NOT_DISPOSE disposal method.
    GifFrame(java.awt.Image image, int layoutConstraint, int disposalMethod)
              Constructs GifFrame from the specified Image with the relative position (final position is calculated according to one of the predifined layout constraint before the final encoding process starts), indefinite delay and one of the predefined disposal methods.
    GifFrame(java.awt.Image image, int layoutConstraint, int disposalMethod, int delay)
              Constructs GifFrame from the specified Image with the relative position (final position is calculated according to one of the predifined layout constraint before the final encoding process starts), the specified delay and one of the predefined disposal methods.
    GifFrame(java.awt.Image image, java.awt.Point position)
              Constructs GifFrame from the specified Image with the specified absolute position, indefinite delay and DISPOSAL_METHOD_DO_NOT_DISPOSE disposal method.
    GifFrame(java.awt.Image image, java.awt.Point position, int disposalMethod)
              Constructs GifFrame from the specified Image with the specified absolute position, one of the predefined disposal methods and indefinite delay.
    GifFrame(java.awt.Image image, java.awt.Point position, int disposalMethod, int delay)
              Constructs GifFrame from the specified Image with the specified absolute position, delay and one of the predefined disposal methods.
     
    Method Summary
     void setDelay(int delay)
              Set the specified delay time
     void setDisposalMethod(int disposalMethod)
              Set the one of the predefined disposal methods to this GifFrame
     void setInterlaced(boolean interlaced)
              Set interlace flag - indicates if the image is interlaced.
     void setLayoutConstraint(int layoutConstraint)
              Set the relative position of the this GifFrame (final position is calculated according to one of the predefined layout constraints before the final encoding process starts)
     
    Methods inherited from class java.lang.Object
    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    DISPOSAL_METHOD_NOT_SPECIFIED

    public static final int DISPOSAL_METHOD_NOT_SPECIFIED
    No disposal specified. The decoder is not required to take any action.

    See Also:
    Constant Field Values

    DISPOSAL_METHOD_DO_NOT_DISPOSE

    public static final int DISPOSAL_METHOD_DO_NOT_DISPOSE
    Do not dispose. The graphic is to be left in place.

    See Also:
    Constant Field Values

    DISPOSAL_METHOD_RESTORE_TO_BACKGROUND_COLOR

    public static final int DISPOSAL_METHOD_RESTORE_TO_BACKGROUND_COLOR
    Restore to background color. The area used by the graphic must be restored to the background color.

    See Also:
    Constant Field Values

    DISPOSAL_METHOD_RESTORE_TO_PREVIOUS

    public static final int DISPOSAL_METHOD_RESTORE_TO_PREVIOUS
    Restore to previous. The decoder is required to restore the area overwritten by the graphic with what was there prior to rendering the graphic.

    See Also:
    Constant Field Values

    LAYOUT_TOP_LEFT

    public static final int LAYOUT_TOP_LEFT
    The top-left layout constraint.

    See Also:
    Constant Field Values

    LAYOUT_TOP_CENTER

    public static final int LAYOUT_TOP_CENTER
    The top-center layout constraint

    See Also:
    Constant Field Values

    LAYOUT_TOP_RIGHT

    public static final int LAYOUT_TOP_RIGHT
    The top-right layout constraint.

    See Also:
    Constant Field Values

    LAYOUT_MIDDLE_LEFT

    public static final int LAYOUT_MIDDLE_LEFT
    The middle-left layout constraint.

    See Also:
    Constant Field Values

    LAYOUT_MIDDLE_CENTER

    public static final int LAYOUT_MIDDLE_CENTER
    The middle-center layout constraint.

    See Also:
    Constant Field Values

    LAYOUT_MIDDLE_RIGHT

    public static final int LAYOUT_MIDDLE_RIGHT
    The middle-right layout constraint.

    See Also:
    Constant Field Values

    LAYOUT_BOTTOM_LEFT

    public static final int LAYOUT_BOTTOM_LEFT
    The bottom-left layout constraint.

    See Also:
    Constant Field Values

    LAYOUT_BOTTOM_CENTER

    public static final int LAYOUT_BOTTOM_CENTER
    The bottom-center layout constraint.

    See Also:
    Constant Field Values

    LAYOUT_BOTTOM_RIGHT

    public static final int LAYOUT_BOTTOM_RIGHT
    The bottom-right layout constraint.

    See Also:
    Constant Field Values
    Constructor Detail

    GifFrame

    public GifFrame(java.awt.Image image)
             throws java.lang.InterruptedException
    Constructs GifFrame from the specified Image with the absolute position (0,0), indefinite delay and DISPOSAL_METHOD_DO_NOT_DISPOSE disposal method.

    Parameters:
    image - image to init frame from
    Throws:
    java.lang.NullPointerException - If image is null
    java.lang.InterruptedException - if image loading fails

    GifFrame

    public GifFrame(java.awt.Image image,
                    int layoutConstraint)
             throws java.lang.InterruptedException
    Constructs GifFrame from the specified Image with the relative position (final position is calculated according to one of the predifined layout constraint before the final encoding process starts), indefinite delay and DISPOSAL_METHOD_DO_NOT_DISPOSE disposal method.

    Parameters:
    image - image to init frame from
    layoutConstraint - one of the predefined layout constraints: LAYOUT_TOP_LEFT, LAYOUT_TOP_CENTER, LAYOUT_TOP_RIGHT, LAYOUT_MIDDLE_LEFT, LAYOUT_MIDDLE_CENTER, LAYOUT_MIDDLE_RIGHT, LAYOUT_BOTTOM_LEFT, LAYOUT_BOTTOM_CENTER, LAYOUT_BOTTOM_RIGHT
    Throws:
    java.lang.NullPointerException - If image is null
    java.lang.IllegalArgumentException - If unknown layout constraint
    java.lang.InterruptedException - if image loading fails

    GifFrame

    public GifFrame(java.awt.Image image,
                    int layoutConstraint,
                    int disposalMethod)
             throws java.lang.InterruptedException
    Constructs GifFrame from the specified Image with the relative position (final position is calculated according to one of the predifined layout constraint before the final encoding process starts), indefinite delay and one of the predefined disposal methods.

    Parameters:
    image - image to init frame from
    layoutConstraint - one of the predefined layout constraints: LAYOUT_TOP_LEFT, LAYOUT_TOP_CENTER, LAYOUT_TOP_RIGHT, LAYOUT_MIDDLE_LEFT, LAYOUT_MIDDLE_CENTER, LAYOUT_MIDDLE_RIGHT, LAYOUT_BOTTOM_LEFT, LAYOUT_BOTTOM_CENTER, LAYOUT_BOTTOM_RIGHT
    disposalMethod - one of the predefined disposal methods: DISPOSAL_METHOD_NOT_SPECIFIED, DISPOSAL_METHOD_DO_NOT_DISPOSE, DISPOSAL_METHOD_RESTORE_TO_PREVIOUS, DISPOSAL_METHOD_RESTORE_TO_BACKGROUND_COLOR
    Throws:
    java.lang.NullPointerException - If image is null
    java.lang.IllegalArgumentException - If unknown disposal method
    java.lang.IllegalArgumentException - If unknown layout constraint
    java.lang.InterruptedException - if image loading fails

    GifFrame

    public GifFrame(java.awt.Image image,
                    int layoutConstraint,
                    int disposalMethod,
                    int delay)
             throws java.lang.InterruptedException
    Constructs GifFrame from the specified Image with the relative position (final position is calculated according to one of the predifined layout constraint before the final encoding process starts), the specified delay and one of the predefined disposal methods.

    Parameters:
    image - image to init frame from
    layoutConstraint - one of the predefined layout constraints: LAYOUT_TOP_LEFT, LAYOUT_TOP_CENTER, LAYOUT_TOP_RIGHT, LAYOUT_MIDDLE_LEFT, LAYOUT_MIDDLE_CENTER, LAYOUT_MIDDLE_RIGHT, LAYOUT_BOTTOM_LEFT, LAYOUT_BOTTOM_CENTER, LAYOUT_BOTTOM_RIGHT
    disposalMethod - one of the predefined disposal methods: DISPOSAL_METHOD_NOT_SPECIFIED, DISPOSAL_METHOD_DO_NOT_DISPOSE, DISPOSAL_METHOD_RESTORE_TO_PREVIOUS, DISPOSAL_METHOD_RESTORE_TO_BACKGROUND_COLOR
    delay - the specified delay time in 1/100 seconds (100 means 1 second delay)
    Throws:
    java.lang.NullPointerException - image is null
    java.lang.IllegalArgumentException - If unknown disposal method
    java.lang.IllegalArgumentException - If unknown layout constraint
    java.lang.InterruptedException - if image loading fails

    GifFrame

    public GifFrame(java.awt.Image image,
                    java.awt.Point position)
             throws java.lang.InterruptedException
    Constructs GifFrame from the specified Image with the specified absolute position, indefinite delay and DISPOSAL_METHOD_DO_NOT_DISPOSE disposal method.

    Parameters:
    image - image to init frame from
    position - absolute position
    Throws:
    java.lang.NullPointerException - If image is null
    java.lang.InterruptedException - if image loading fails

    GifFrame

    public GifFrame(java.awt.Image image,
                    java.awt.Point position,
                    int disposalMethod)
             throws java.lang.InterruptedException
    Constructs GifFrame from the specified Image with the specified absolute position, one of the predefined disposal methods and indefinite delay.

    Parameters:
    image - image to init frame from
    position - absolute position
    disposalMethod - one of the predefined disposal methods: DISPOSAL_METHOD_NOT_SPECIFIED, DISPOSAL_METHOD_DO_NOT_DISPOSE, DISPOSAL_METHOD_RESTORE_TO_PREVIOUS, DISPOSAL_METHOD_RESTORE_TO_BACKGROUND_COLOR
    Throws:
    java.lang.NullPointerException - If image is null
    java.lang.IllegalArgumentException - If unknown disposal method
    java.lang.InterruptedException - if image loading fails

    GifFrame

    public GifFrame(java.awt.Image image,
                    java.awt.Point position,
                    int disposalMethod,
                    int delay)
             throws java.lang.InterruptedException
    Constructs GifFrame from the specified Image with the specified absolute position, delay and one of the predefined disposal methods.

    Parameters:
    image - image to init frame from
    position - absolute position
    disposalMethod - one of the predefined disposal methods: DISPOSAL_METHOD_NOT_SPECIFIED, DISPOSAL_METHOD_DO_NOT_DISPOSE, DISPOSAL_METHOD_RESTORE_TO_PREVIOUS, DISPOSAL_METHOD_RESTORE_TO_BACKGROUND_COLOR
    delay - the specified delay time in 1/100 seconds (100 means 1 second delay)
    Throws:
    java.lang.NullPointerException - If image is null
    java.lang.IllegalArgumentException - If unknown disposal method
    java.lang.InterruptedException - if image loading fails
    Method Detail

    setDisposalMethod

    public void setDisposalMethod(int disposalMethod)
    Set the one of the predefined disposal methods to this GifFrame

    Parameters:
    disposalMethod - one of the predefined disposal methods: DISPOSAL_METHOD_NOT_SPECIFIED, DISPOSAL_METHOD_DO_NOT_DISPOSE, DISPOSAL_METHOD_RESTORE_TO_PREVIOUS, DISPOSAL_METHOD_RESTORE_TO_BACKGROUND_COLOR
    Throws:
    java.lang.IllegalArgumentException - If unknown disposal method

    setLayoutConstraint

    public void setLayoutConstraint(int layoutConstraint)
    Set the relative position of the this GifFrame (final position is calculated according to one of the predefined layout constraints before the final encoding process starts)

    Parameters:
    layoutConstraint - one of the predefined layout constraints: LAYOUT_TOP_LEFT, LAYOUT_TOP_CENTER, LAYOUT_TOP_RIGHT, LAYOUT_MIDDLE_LEFT, LAYOUT_MIDDLE_CENTER, LAYOUT_MIDDLE_RIGHT, LAYOUT_BOTTOM_LEFT, LAYOUT_BOTTOM_CENTER, LAYOUT_BOTTOM_RIGHT
    Throws:
    java.lang.IllegalArgumentException - If unknown layout constraint

    setDelay

    public void setDelay(int delay)
    Set the specified delay time

    Parameters:
    delay - the specified delay time in 1/100 seconds (100 means 1 second delay)

    setInterlaced

    public void setInterlaced(boolean interlaced)
    Set interlace flag - indicates if the image is interlaced. An image is interlaced in a four-pass interlace pattern.

    Parameters:
    interlaced - interlace flag