Construct a GIF Frame
The GifFrame java class
is used as a container to aggregate and encode the gif format specific information about a single gif image frame.
GifFrame constructors can be divided into 2 types according to the desired frame position (absolute or relative).
"absolute positioning" costructors contain Point parameter and
"relative positioning" constructors contain layout constraint parameter.
Note: If you use "relative positioning" then
the final position is calculated according to one of the predifined layout constraint
before the final encoding process starts.
Absolute and Relative Internal GIF Frame Positioning
Below examples demostrate relative positioning and how you can use it (see examples/FramePositioning):

(size: 300x300, every frame size: 100x100)

(size: 200x200, every frame size: 100x100)

image tour (size: 300x240, every frame is scaled down using ImageUtils to 150x130)
Get Frame's Position and Size
You can get frame's position and size using the next methods:
public int getX();
public int getY();
public int getWidth();
public int getHeight();
Disposal Methods & Delay Time
Disposal Method - indicates the way in which the graphic is to be treated after being displayed.
According to Gif89a format specification there are 4 disposal methods:
Not Specified,
Do Not Dispose,
Restore To Background Color and
Restore To Previous.
You can set disposal method through corresponding GifFrame
constructors or using the next method:
public void setDisposalMethod(int disposalMethod)
You can get disposal method using the next method:
public int getDisposalMethod()
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.
You can set delay time through corresponding GifFrame
constructors or using the next method:
public void setDelay(int delay)
You can get frame's delay time using the next method:
public int getDelay()
Adding GIF Frames to a GIF Image
To add GifFrame(s) to GifImage(s)
you can use the next methods (please consult GifFrame API for more information):
public GifImage addGifFrame(GifFrame frame);
public GifImage addGifFrame(GifFrame frame, MorphingFilter filter);
public GifImage addGifFrame(GifFrame frame, Watermark watermark);
public GifImage addGifFrame(GifFrame frame, MorphingFilter filter, Watermark watermark);
Retrieve Frame's Image Data and Color Model
To retrieve a copy of the frame's image data as an instance of Image or BufferedImage java classes
you should use the next methods:
public Image getAsImage();
public BufferedImage getAsBufferedImage();
To retrieve a copy of the frame's image color model as an instance of IndexColorModel the next method can be used:
public IndexColorModel getColorModel();
Hint: You can use a copy of the frame's image color model to get frame's transparency information
through IndexColorModel methods: hasAlpha(), getTransparency(), getTransparentPixel() etc.
|