-
- All Implemented Interfaces:
-
java.lang.AutoCloseable
public final class Gif implements AutoCloseable
Representation of the gif, with methods to decode frames. This class's methods are not thread safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classGif.Companion
-
Field Summary
Fields Modifier and Type Field Description private final IntegercurrentIndexprivate final LongcurrentDelayprivate final Dimensiondimensionprivate final IntegerframeCountprivate final LoopCountloopCountprivate final DoubleaspectRatioprivate final IntegerbackgroundColorprivate final BooleanisAnimatedprivate final IntegerpreviousIndex
-
Constructor Summary
Constructors Constructor Description Gif(GifDescriptor gifDescriptor)
-
Method Summary
Modifier and Type Method Description final IntegergetCurrentIndex()final LonggetCurrentDelay()final DimensiongetDimension()The dimensions of the GIF, width and height. final IntegergetFrameCount()How many frames in the GIF. final LoopCountgetLoopCount()For animated gif, the loop count policy: should never loop, should loop forever or should loop a set amount of time. final DoublegetAspectRatio()The Pixel Aspect Ratio is defined to be the quotient of the pixel's width over its height. final IntegergetBackgroundColor()The background color as read from the global color table, default to transparent if not set. final BooleanisAnimated()A gif with more than 1 frame will be animated. final IntegergetPreviousIndex(Integer $self)final Result<Unit>advance()Advance the frame index, decode the new frame, looping back to zero after the last frame has been reached. final Result<IntArray>getCurrentFrame(IntArray inPixels)Write the current frame in the int array. final Result<IntArray>getFrame(Integer index)Get the frame at set index, returning a int array. final Result<IntArray>getFrame(Integer index, IntArray inPixels)Get the frame at set index, writing it in the provided int array. final LonggetDelay(Integer index)Returns the delay time of the specified frame, in millisecond. Unitclose()-
-
Constructor Detail
-
Gif
Gif(GifDescriptor gifDescriptor)
-
-
Method Detail
-
getCurrentIndex
final Integer getCurrentIndex()
-
getCurrentDelay
final Long getCurrentDelay()
-
getDimension
final Dimension getDimension()
The dimensions of the GIF, width and height.
-
getFrameCount
final Integer getFrameCount()
How many frames in the GIF. If more than 1, we have an animated GIF.
-
getLoopCount
final LoopCount getLoopCount()
For animated gif, the loop count policy: should never loop, should loop forever or should loop a set amount of time.
-
getAspectRatio
final Double getAspectRatio()
The Pixel Aspect Ratio is defined to be the quotient of the pixel's width over its height. The value range in this field allows specification of the widest pixel of 4:1 to the tallest pixel of 1:4
-
getBackgroundColor
final Integer getBackgroundColor()
The background color as read from the global color table, default to transparent if not set.
-
isAnimated
final Boolean isAnimated()
A gif with more than 1 frame will be animated.
-
getPreviousIndex
final Integer getPreviousIndex(Integer $self)
-
advance
final Result<Unit> advance()
Advance the frame index, decode the new frame, looping back to zero after the last frame has been reached. Does not care about loop count.
-
getCurrentFrame
final Result<IntArray> getCurrentFrame(IntArray inPixels)
Write the current frame in the int array.
- Parameters:
inPixels- The buffer where the pixels will be written.
-
getFrame
final Result<IntArray> getFrame(Integer index)
Get the frame at set index, returning a int array. It will internally advance the current frame counter if needed, and draw each needed frame it turn, to make sure the result is consistent.
- Parameters:
index- The index of the frame to decode and return.
-
getFrame
final Result<IntArray> getFrame(Integer index, IntArray inPixels)
Get the frame at set index, writing it in the provided int array. It will internally advance the current frame counter if needed, and draw each needed frame it turn, to make sure the result is consistent.
- Parameters:
index- The index of the frame to decode and return.inPixels- The buffer where the pixels will be written.
-
getDelay
final Long getDelay(Integer index)
Returns the delay time of the specified frame, in millisecond. This delay represents how long we should show this frame before displaying the next one in the animation. If the gif is not animated, returns zero. Some animated GIFs have a specified delay of 0L, meaning we should draw the next frame as fast as possible. Most web browsers opt to draw a frame every 32 milliseconds if the delay is set to 0L.
- Parameters:
index- The index of the frame we want the delay for.
-
-
-
-