Packages

 

com.aspose.imaging.fileformats.gif.blocks

Class GifFrameBlock

    • Field Detail

      • EXTENSION_LABEL

        public static final int EXTENSION_LABEL

        Block extension label.

        See Also:
        Constant Field Values
      • IMAGE_DESCRIPTOR_SIZE

        public static final int IMAGE_DESCRIPTOR_SIZE

        The image descriptor size.

        See Also:
        Constant Field Values
    • Constructor Detail

      • GifFrameBlock

        public GifFrameBlock(int width,
                             int height)

        Initializes a new instance of the GifFrameBlock class.

        Parameters:
        width - The image width.
        height - The image height.
        Code example:

        The following example shows how to compose an animated GIF image from individual GIF blocks.


        String dir = "c:\\temp\\";
        
        // Create a GIF image 100 x 100 px.
        // The first block is fully black by default.
        com.aspose.imaging.fileformats.gif.blocks.GifFrameBlock firstBlock = new com.aspose.imaging.fileformats.gif.blocks.GifFrameBlock(100, 100);
        com.aspose.imaging.fileformats.gif.GifImage gifImage = new com.aspose.imaging.fileformats.gif.GifImage(firstBlock);
        try {
            // The first circle is red
            com.aspose.imaging.brushes.SolidBrush brush1 = new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getRed());
        
            // The second circle is black
            com.aspose.imaging.brushes.SolidBrush brush2 = new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getBlack());
        
            // Gradually increase the angle of the red arc shape.
            for (int angle = 10; angle <= 360; angle += 10) {
                com.aspose.imaging.fileformats.gif.blocks.GifFrameBlock block = new com.aspose.imaging.fileformats.gif.blocks.GifFrameBlock(100, 100);
        
                com.aspose.imaging.Graphics gr = new com.aspose.imaging.Graphics(block);
                gr.fillPie(brush1, block.getBounds(), 0, angle);
        
                gifImage.addBlock(block);
            }
        
            // Gradually increase the angle of the black arc and wipe out the red arc.
            for (int angle = 10; angle <= 360; angle += 10) {
                com.aspose.imaging.fileformats.gif.blocks.GifFrameBlock block = new com.aspose.imaging.fileformats.gif.blocks.GifFrameBlock(100, 100);
        
                com.aspose.imaging.Graphics gr = new com.aspose.imaging.Graphics(block);
                gr.fillPie(brush2, block.getBounds(), 0, angle);
                gr.fillPie(brush1, block.getBounds(), angle, 360 - angle);
        
                gifImage.addBlock(block);
            }
        
            gifImage.save(dir + "animated_radar.gif");
        } finally {
            firstBlock.dispose();
            gifImage.dispose();
        }
        

      • GifFrameBlock

        public GifFrameBlock(int left,
                             int top,
                             int width,
                             int height)

        Initializes a new instance of the GifFrameBlock class.

        Parameters:
        left - The left image position.
        top - The top image position.
        width - The image width.
        height - The image height.
      • GifFrameBlock

        public GifFrameBlock(int left,
                             int top,
                             int width,
                             int height,
                             IColorPalette colorPalette,
                             boolean isPaletteSorted,
                             boolean isGifFrameInterlaced,
                             byte bitsPerPixel)

        Initializes a new instance of the GifFrameBlock class.

        Parameters:
        left - The left image position.
        top - The top image position.
        width - The image Width.
        height - The image Height.
        colorPalette - The color palette.
        isPaletteSorted - if set to true the color palette is sorted.
        isGifFrameInterlaced - if set to true the GIF frame is interlaced.
        bitsPerPixel - The bits per pixel.
      • GifFrameBlock

        public GifFrameBlock(RasterImage image)

        Initializes a new instance of the GifFrameBlock class.

        Parameters:
        image - The image to initialize frame pixel and palette data with.
      • GifFrameBlock

        public GifFrameBlock(RasterImage image,
                             int left,
                             int top)

        Initializes a new instance of the GifFrameBlock class.

        Parameters:
        image - The image to initialize frame pixel and palette data with.
        left - The left image position.
        top - The top image position.
      • GifFrameBlock

        public GifFrameBlock(RasterImage image,
                             int left,
                             int top,
                             boolean isPaletteSorted,
                             boolean isGifFrameInterlaced,
                             byte lzwCodeSize)

        Initializes a new instance of the GifFrameBlock class.

        Parameters:
        image - The image to initialize frame pixel and palette data with.
        left - The left image position.
        top - The top image position.
        isPaletteSorted - if set to true the color palette is sorted.
        isGifFrameInterlaced - if set to true the GIF frame is interlaced.
        lzwCodeSize - The bits per pixel.
      • GifFrameBlock

        public GifFrameBlock(InputStream stream)

        Initializes a new instance of the GifFrameBlock class.

        Parameters:
        stream - The stream to load an image from and initialize frame pixel and palette data with.
      • GifFrameBlock

        public GifFrameBlock(com.aspose.ms.System.IO.Stream stream)
      • GifFrameBlock

        public GifFrameBlock(InputStream stream,
                             int left,
                             int top)

        Initializes a new instance of the GifFrameBlock class.

        Parameters:
        stream - The stream to load an image from and initialize frame pixel and palette data with.
        left - The left image position.
        top - The top image position.
      • GifFrameBlock

        public GifFrameBlock(InputStream stream,
                             int left,
                             int top,
                             boolean isPaletteSorted,
                             boolean isGifFrameInterlaced,
                             byte lzwCodeSize)

        Initializes a new instance of the GifFrameBlock class.

        Parameters:
        stream - The stream to load an image from and initialize frame pixel and palette data with.
        left - The left image position.
        top - The top image position.
        isPaletteSorted - if set to true the color palette is sorted.
        isGifFrameInterlaced - if set to true the GIF frame is interlaced.
        lzwCodeSize - The bits per pixel.
      • GifFrameBlock

        public GifFrameBlock(String path)

        Initializes a new instance of the GifFrameBlock class.

        Parameters:
        path - The path to load an image from and initialize frame pixel and palette data with.
      • GifFrameBlock

        public GifFrameBlock(String path,
                             int left,
                             int top)

        Initializes a new instance of the GifFrameBlock class.

        Parameters:
        path - The path to load an image from and initialize frame pixel and palette data with.
        left - The left image position.
        top - The top image position.
      • GifFrameBlock

        public GifFrameBlock(String path,
                             int left,
                             int top,
                             boolean isPaletteSorted,
                             boolean isGifFrameInterlaced,
                             byte lzwCodeSize)

        Initializes a new instance of the GifFrameBlock class.

        Parameters:
        path - The path to load an image from and initialize frame pixel and palette data with.
        left - The left image position.
        top - The top image position.
        isPaletteSorted - if set to true the color palette is sorted.
        isGifFrameInterlaced - if set to true the GIF frame is interlaced.
        lzwCodeSize - The bits per pixel.
    • Method Detail

      • getColorPalette

        public static IColorPalette getColorPalette(IColorPalette framePalette,
                                                    IColorPalette containerPalette)

        Gets the associated color palette.

        Parameters:
        framePalette - The frame palette.
        containerPalette - The container palette.
        Returns:
        The color palette.
      • createFlags

        public static byte createFlags(IColorPalette colorPalette,
                                       boolean isPaletteSorted,
                                       boolean isGifFrameInterlaced)

        Creates the flags.

        Parameters:
        colorPalette - The color palette.
        isPaletteSorted - if set to true the colors in color palette are sorted.
        isGifFrameInterlaced - if set to true the GIF frame image is interlaced.
        Returns:
        The created flags.
      • getFileFormat

        public long getFileFormat()

        Gets a value of file format

        Overrides:
        getFileFormat in class Image
      • getBitsPerPixel

        public int getBitsPerPixel()

        Gets the image bits per pixel count.

        Specified by:
        getBitsPerPixel in class Image
        Returns:
        The image bits per pixel count.
      • getFrameTime

        public final int getFrameTime()

        Gets the duration.

        Value: The duration. <autogeneratedoc></autogeneratedoc>
        Specified by:
        getFrameTime in interface IAnimationFrame
        Returns:
        the duration.
      • getInterlaced

        public boolean getInterlaced()

        Gets or sets a value indicating whether this GifFrameBlock is interlaced.

        Returns:
        true if interlaced; otherwise, false.
      • setInterlaced

        public void setInterlaced(boolean value)

        Gets or sets a value indicating whether this GifFrameBlock is interlaced.

        Parameters:
        value - true if interlaced; otherwise, false.
      • isPaletteSorted

        public boolean isPaletteSorted()

        Gets or sets a value indicating whether color palette is sorted.

        Returns:
        true if color palette is sorted; otherwise, false.
      • setPaletteSorted

        public void setPaletteSorted(boolean value)

        Gets or sets a value indicating whether color palette is sorted.

        Parameters:
        value - true if color palette is sorted; otherwise, false.
      • getGifFrameBitsPerPixel

        public byte getGifFrameBitsPerPixel()

        Gets or sets the GIF frame bits per pixel.

        Returns:
        The GIF frame bits per pixel.
      • setGifFrameBitsPerPixel

        public void setGifFrameBitsPerPixel(byte value)

        Gets or sets the GIF frame bits per pixel.

        Parameters:
        value - The GIF frame bits per pixel.
      • getLeft

        public int getLeft()

        Gets or sets the left image location.

        Returns:
        The left image location.
      • setLeft

        public void setLeft(int value)

        Gets or sets the left image location.

        Parameters:
        value - The left image location.
      • getTop

        public int getTop()

        Gets or sets the top image location.

        Returns:
        The top image location.
      • setTop

        public void setTop(int value)

        Gets or sets the top image location.

        Parameters:
        value - The top image location.
      • getFrameTop

        public final int getFrameTop()

        Converts to p.

        Value: The top. <autogeneratedoc></autogeneratedoc>
        Specified by:
        getFrameTop in interface IAnimationFrame
      • getFrameLeft

        public final int getFrameLeft()

        Gets the left.

        Value: The left. <autogeneratedoc></autogeneratedoc>
        Specified by:
        getFrameLeft in interface IAnimationFrame
        Returns:
        the left.
      • getFlags

        public byte getFlags()

        Gets or sets the flags.

        Returns:
        The flags.
      • setFlags

        public void setFlags(byte value)

        Gets or sets the flags.

        Parameters:
        value - The flags.
      • getControlBlock

        public GifGraphicsControlBlock getControlBlock()

        Gets the graphics control block associated with this block.

        Returns:
        The control block.
      • hasTransparentColor

        public boolean hasTransparentColor()

        Gets a value indicating whether frame block has transparent color.

        Overrides:
        hasTransparentColor in class RasterImage
      • setTransparentColor

        public void setTransparentColor(boolean value)

        Gets a value indicating whether frame block has transparent color.

        Overrides:
        setTransparentColor in class RasterImage
      • adjustBrightness

        public void adjustBrightness(int brightness)

        Adjust of a brightness for image.

        Overrides:
        adjustBrightness in class RasterCachedImage
        Parameters:
        brightness - Brightness value.
      • replaceColor

        public void replaceColor(int oldColorArgb,
                                 byte oldColorDiff,
                                 int newColorArgb)

        Replaces one color to another with allowed difference and preserves original alpha value to save smooth edges.

        Overrides:
        replaceColor in class RasterImage
        Parameters:
        oldColorArgb - Old color ARGB value to be replaced.
        oldColorDiff - Allowed difference in old color to be able to widen replaced color tone.
        newColorArgb - New color ARGB value to replace old color with.
      • replaceNonTransparentColors

        public void replaceNonTransparentColors(int newColorArgb)

        Replaces all non-transparent colors with new color and preserves original alpha value to save smooth edges. Note: if you use it on images without transparency, all colors will be replaced with a single one.

        Overrides:
        replaceNonTransparentColors in class RasterImage
        Parameters:
        newColorArgb - New color ARGB value to replace non transparent colors with.