Package 

Class Gif

  • 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.

    • Method Detail

      • 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.

      • 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.