|
|||||||||||
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 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 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_CURRENT
GifImage(int resizeStrategy)
,GifImage(int width, int height, int resizeStrategy)
setDefaultDelay(int delay)
setLoopNumber(int number)
GifFrame
,
GifEncoder
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 | |
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. |
int |
getCurrentLogicHeight()
get current logic screen height |
int |
getCurrentLogicWidth()
get current logic screen width |
GifFrame |
getLastFrame()
Returns the last added frame |
void |
setDefaultDelay(int delay)
Set default delay between frames. |
void |
setLoopNumber(int number)
Set number of iterations the loop should be executed. |
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_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.
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.
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_CURRENT
java.lang.IllegalArgumentException
- If width and/or height parameter less than 1.Method Detail |
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, Watermark watermark)
frame
- GifFrame
to addwatermark
- Watermark
to apply
GifImage
instance
java.lang.NullPointerException
- If frame to add is null.Watermark
,
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 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 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 int getCurrentLogicWidth()
public int getCurrentLogicHeight()
public GifFrame getLastFrame()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |