|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.gif4j.GifImage
An instance of this java class is used to represent a gif image as
a sequence of one or more frames (instances of GifFrame class) and to
contain the next general gif image specific parameters:
GifFrame has his own Local Color Table,
but to optimize final image size (every Local Color Table takes up to 768 bytes)
you can force Global Color Table usage (see GifEncoder.encode(GifImage gifImage, java.io.OutputStream outputStream, boolean forceGlobalColorTableUsage)).
In this case local color tables will be union to global color table. This feature is recommended to use for images with a lot of GifFrames.
To add new frame the next methods can be used:
addGifFrame(GifFrame frame),
addGifFrame(GifFrame frame, MorphingFilter filter),
addGifFrame(GifFrame frame, Watermark watermark),
addGifFrame(GifFrame frame, MorphingFilter filter, Watermark watermark)
GifImage is also used to control the next general parameters:
RESIZE_STRATEGY_CROP_TO_FIT_IMAGE_SIZE,RESIZE_STRATEGY_SCALE_TO_FIT_IMAGE_SIZE,RESIZE_STRATEGY_EXTEND_TO_CURRENTGifImage(int resizeStrategy),GifImage(int width, int height, int resizeStrategy)
setDefaultDelay(int delay)setLoopNumber(int number)
Hint: Use GifDecoder java class to load and decode GIF images into GifImage(-s) from input streams and files.
Use GifEncoder java class to encode and save GifImage(-s) into the GIF89a image file format to output streams and files.
GifFrame,
GifEncoder,
GifDecoder| Field Summary | |
static int |
RESIZE_STRATEGY_CROP_TO_FIT_IMAGE_SIZE
Represents a resize strategy, when every subsequent image frame is necessarily resized by cropping to fit the fixed logical screen size. |
static int |
RESIZE_STRATEGY_EXTEND_TO_CURRENT
Represents a resize strategy, when logical screen width and height are necessarily extended to support the adding frame's size. |
static int |
RESIZE_STRATEGY_SCALE_TO_FIT_IMAGE_SIZE
Represents a resize strategy, when every subsequent image frame is necessarily resized by scaling to fit the fixed logical screen size. |
| Constructor Summary | |
GifImage()
Constructs GifImage with RESIZE_STRATEGY_EXTEND_TO_CURRENT resize strategy
and indefinite general gif image width and height (these parameters will be taken from the first added GifFrame). |
|
GifImage(int resizeStrategy)
Constructs GifImage of one of the predefined resize strategies
and indefinite logical screen width and height (these parameters will be taken from the first added GifFrame). |
|
GifImage(int width,
int height)
Constructs GifImage with RESIZE_STRATEGY_SCALE_TO_FIT_IMAGE_SIZE resize strategy
and the specified general logical screen width and height. |
|
GifImage(int width,
int height,
int resizeStrategy)
Constructs GifImage of one of the predefined resize strategies and
general logical screen width and height. |
|
| Method Summary | |
void |
addComment(java.lang.String comment)
Add ASCII textual comment to be embedded in this GIF image. |
GifImage |
addGifFrame(GifFrame frame)
Add the specified frame to the end of the internal sequence. |
GifImage |
addGifFrame(GifFrame frame,
MorphingFilter filter)
Add the specified frame to the end of the internal sequence and set the specified morphing filter which will be applied to adding frame before the encoding process starts. |
GifImage |
addGifFrame(GifFrame frame,
MorphingFilter filter,
Watermark watermark)
Add the specified frame to the end of the internal sequence, set the specified morphing filter and watermark which will be applied to adding frame before the encoding process starts. |
GifImage |
addGifFrame(GifFrame frame,
Watermark watermark)
Add the specified frame to the end of the internal sequence and set the specified watermark which will be applied to adding frame before the encoding process starts. |
java.util.Iterator |
comments()
Returns an iterator over the elements in the comments array or null if comments array is empty. |
java.util.Iterator |
frames()
Returns an iterator over the frames ( GifFrame instances) in the current frames sequence. |
java.lang.String |
getComment(int index)
Returns ASCII textual comment as a String from comments array at the specified index. |
int |
getCurrentLogicHeight()
Returns current logic screen height |
int |
getCurrentLogicWidth()
Returns current logic screen width |
GifFrame |
getFrame(int index)
Returns GifFrame at the specified index in the current frames sequence. |
GifFrame |
getLastFrame()
Returns the last GifFrame in the current frames sequence |
int |
getLoopNumber()
Returns number of animated gif image loop iterations |
int |
getNumberOfComments()
Returns the number of text comments in the comments array. |
int |
getNumberOfFrames()
Returns the number of frames in the current frames sequence. |
int |
getScreenHeight()
Returns gif image logic screen height |
int |
getScreenWidth()
Returns gif image logic screen width |
java.awt.Color |
getTransparentColor()
Returns the transparent color set by setTransparentColor(java.awt.Color) method. |
java.lang.String |
getVersion()
Get GIF image format version number. |
void |
removeComment(int index)
Remove ASCII textual comment from comments array at the specified index. |
void |
setDefaultDelay(int delay)
Set default delay between frames. |
void |
setLoopNumber(int number)
Set number of iterations the loop should be executed. |
void |
setTransparentColor(java.awt.Color color)
Set the transparent color to replace a source transparent color in GIF image palette |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int RESIZE_STRATEGY_CROP_TO_FIT_IMAGE_SIZE
Represents a resize strategy, when every subsequent image frame is necessarily resized by cropping to fit the fixed logical screen size.
public static final int RESIZE_STRATEGY_EXTEND_TO_CURRENT
Represents a resize strategy, when logical screen width and height are necessarily extended to support the adding frame's size.
This strategy is used by default.
public static final int RESIZE_STRATEGY_SCALE_TO_FIT_IMAGE_SIZE
Represents a resize strategy, when every subsequent image frame is necessarily resized by scaling to fit the fixed logical screen size.
| Constructor Detail |
public GifImage()
GifImage with RESIZE_STRATEGY_EXTEND_TO_CURRENT resize strategy
and indefinite general gif image width and height (these parameters will be taken from the first added GifFrame).
public GifImage(int resizeStrategy)
GifImage of one of the predefined resize strategies
and indefinite logical screen width and height (these parameters will be taken from the first added GifFrame).
resizeStrategy - one of the predefined resize strategies:RESIZE_STRATEGY_CROP_TO_FIT_IMAGE_SIZE,RESIZE_STRATEGY_SCALE_TO_FIT_IMAGE_SIZE,RESIZE_STRATEGY_EXTEND_TO_CURRENT
public GifImage(int width,
int height)
GifImage with RESIZE_STRATEGY_SCALE_TO_FIT_IMAGE_SIZE resize strategy
and the specified general logical screen width and height. All added frames will be validated and resized if need to fit these width and height.
width - logical screen width (in pixels)height - logical screen height (in pixels)
java.lang.IllegalArgumentException - If width and/or height parameter less than 1.
public GifImage(int width,
int height,
int resizeStrategy)
GifImage of one of the predefined resize strategies and
general logical screen width and height. All added frames will be validated and resized if need to fit these width and height.
width - logical screen width (in pixels)height - logical screen height (in pixels)resizeStrategy - one of the predefined resize strategies:RESIZE_STRATEGY_CROP_TO_FIT_IMAGE_SIZE,RESIZE_STRATEGY_SCALE_TO_FIT_IMAGE_SIZE,RESIZE_STRATEGY_EXTEND_TO_CURRENTjava.lang.IllegalArgumentException - If width and/or height parameter less than 1.| Method Detail |
public void addComment(java.lang.String comment)
comment - string containing ASCII text comment
java.lang.NullPointerException - If comment string is nullgetComment(int),
getNumberOfComments()public GifImage addGifFrame(GifFrame frame)
frame - GifFrame to add
GifImage instance
java.lang.NullPointerException - If frame to add is null.GifFrame
public GifImage addGifFrame(GifFrame frame,
MorphingFilter filter)
frame - GifFrame to addfilter - MorphingFilter to apply
GifImage instance
java.lang.NullPointerException - If frame to add is null.MorphingFilter,
GifFrame
public GifImage addGifFrame(GifFrame frame,
MorphingFilter filter,
Watermark watermark)
frame - GifFrame to addfilter - MorphingFilter to applywatermark - Watermark to apply
GifImage instance
java.lang.NullPointerException - If frame to add is null.GifFrame,
Watermark,
MorphingFilter
public GifImage addGifFrame(GifFrame frame,
Watermark watermark)
frame - GifFrame to addwatermark - Watermark to apply
GifImage instance
java.lang.NullPointerException - If frame to add is null.Watermark,
GifFramepublic java.util.Iterator comments()
addComment(java.lang.String),
getComment(int),
getNumberOfComments()public java.util.Iterator frames()
GifFrame instances) in the current frames sequence.
getNumberOfFrames()public java.lang.String getComment(int index)
String from comments array at the specified index.
index - the index of the comment to be retrieved
java.lang.IllegalArgumentException - if comments array is empty or
the specified index is invalid (less than 0 or more than or equal to the size of comments array)addComment(java.lang.String),
getNumberOfComments()public int getCurrentLogicHeight()
public int getCurrentLogicWidth()
public GifFrame getFrame(int index)
GifFrame at the specified index in the current frames sequence.
index - the index of the GifFrame to be retrieved
GifFrame at the specified index.
java.lang.IllegalArgumentException - if frames sequence is empty or
the specified index is invalid (less than 0 or more than or equal to the size of frames sequence)getNumberOfFrames()public GifFrame getLastFrame()
GifFrame in the current frames sequence
GifFrame in the current frames sequencepublic int getLoopNumber()
public int getNumberOfComments()
addComment(java.lang.String),
getComment(int)public int getNumberOfFrames()
frames(),
getFrame(int),
getLastFrame()public int getScreenHeight()
public int getScreenWidth()
public java.awt.Color getTransparentColor()
setTransparentColor(java.awt.Color) method. If not set before returns NULL.
setTransparentColor(java.awt.Color) method. If not set before returns NULL.public java.lang.String getVersion()
public void removeComment(int index)
index - the index of the comment to be removed
java.lang.IllegalArgumentException - if comments array is empty or
the specified index is invalid (less than 0 or more than or equal to the size of comments array)addComment(java.lang.String),
getNumberOfComments()public void setDefaultDelay(int delay)
delay - delay time in 1/100 (centiseconds) - value 100 means delay in 1 second.
java.lang.IllegalArgumentException - If delay less than 1.public void setLoopNumber(int number)
number - Number of iterations the loop should be executed:
value of 0 set indefinite looping (is set by default).
Maximum iterations number (excluding indefinite looping) is 65535.
java.lang.IllegalArgumentException - If number less than 0.public void setTransparentColor(java.awt.Color color)
color - transparent color to set
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||