com.aspose.imaging.fileformats.gif
Class GifImage

java.lang.Object
  extended by com.aspose.imaging.DisposableObject
      extended by com.aspose.imaging.DataStreamSupporter
          extended by com.aspose.imaging.Image
              extended by com.aspose.imaging.RasterImage
                  extended by com.aspose.imaging.fileformats.gif.GifImage
All Implemented Interfaces:
IObjectWithBounds

public class GifImage
extends RasterImage

A gif image.


Constructor Summary
GifImage(GifHeader gifHeader, IGifBlock[] blocks, IColorPalette colorPalette, boolean useCompactPalette, boolean hasTrailer, GifFrameBlock activeFrame, boolean changesOccured)
           Initializes a new instance of the GifImage class.
 
Method Summary
 void addBlock(IGifBlock block)
           Adds a new GIF block.
 void clearBlocks()
           Clears all the GIF blocks.
 void flush()
           Flushes all the cached data directly to the object's stream.
 GifFrameBlock getActiveFrame()
           Gets the active frame.
 Color getBackgroundColor()
           Gets the background color.
 byte getBackgroundColorIndex()
           Gets the background color index.
 int getBitsPerPixel()
           Gets the bits per pixel count.
 IGifBlock[] getBlocks()
           Gets the GIF blocks.
 int getHeight()
           Gets the object height.
 java.lang.String getImageLoaderDescriptorName()
           Gets the name of the image loader descriptor.
 int getWidth()
           Gets the object width.
 boolean hasTrailer()
           Gets a value indicating whether GIF has trailer.
 void hasTrailer(boolean value)
           Sets a value indicating whether GIF has trailer.
protected  void onPaletteChanged(IColorPalette oldPalette, IColorPalette newPalette)
           Called when palette is changed.
protected  void onPaletteChanging(IColorPalette oldPalette, IColorPalette newPalette)
           Called when palette is changing.
 void orderBlocks()
           Orders the GIF blocks according to the GIF specification.
protected  void releaseManagedResources()
           Releases the managed resources.
 void removeBlock(IGifBlock block)
           Removes the GIF block.
 void resize(int newWidth, int newHeight, int resizeType)
           Resizes the image.
 void setActiveFrame(GifFrameBlock value)
           Sets the active frame.
 void setBackgroundColor(Color value)
           Sets the background color.
 void setBackgroundColorIndex(byte value)
           Sets the background color index.
 
Methods inherited from class com.aspose.imaging.RasterImage
getHorizontalResolution, getPixel, getVerticalResolution, loadPixels, loadPixelsInternal, readScanLine, rotateFlip, rotateFlip, savePixels, savePixelsInternal, setHorizontalResolution, setPalette, setPixel, setResolution, setVerticalResolution, writeScanLine
 
Methods inherited from class com.aspose.imaging.Image
canLoad, canLoad, canLoad, canLoad, canSave, create, getBounds, getContainer, getFileFormat, getFileFormat, getFitRectangle, getFitRectangle, getFittingRectangle, getFittingRectangle, getPalette, getSize, getUseCompactPalette, load, load, onCompactPaletteUsageChanged, resize, save, save, save, setContainer, setPalette, setUseCompactPalette
 
Methods inherited from class com.aspose.imaging.DataStreamSupporter
getDataStreamContainer, onDataStreamContainerChanging, save, save, setDataStreamContainer
 
Methods inherited from class com.aspose.imaging.DisposableObject
dispose, getDisposed, releaseUnmanagedResources, verifyNotDisposed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GifImage

public GifImage(GifHeader gifHeader,
                IGifBlock[] blocks,
                IColorPalette colorPalette,
                boolean useCompactPalette,
                boolean hasTrailer,
                GifFrameBlock activeFrame,
                boolean changesOccured)

Initializes a new instance of the GifImage class.

Parameters:
gifHeader - The GIF header.
blocks - The GIF blocks.
colorPalette - The color palette.
useCompactPalette - if set to true compact palette is used.
hasTrailer - if set to true GIF has trailer.
activeFrame - The active frame.
changesOccured - if set to true changes were occured and save is required.
Method Detail

addBlock

public void addBlock(IGifBlock block)

Adds a new GIF block.

Parameters:
block - The GIF block to add.

clearBlocks

public void clearBlocks()

Clears all the GIF blocks.


flush

public void flush()

Flushes all the cached data directly to the object's stream.

Overrides:
flush in class DataStreamSupporter

getActiveFrame

public GifFrameBlock getActiveFrame()

Gets the active frame.

Value: The active frame.


getBackgroundColor

public Color getBackgroundColor()

Gets the background color.

Value: The background color.


getBackgroundColorIndex

public byte getBackgroundColorIndex()

Gets the background color index.

Value: The background color index.


getBitsPerPixel

public int getBitsPerPixel()

Gets the bits per pixel count.

Value: The bits per pixel count.


For GIF this value is calculated from active frame.

Specified by:
getBitsPerPixel in class Image

getBlocks

public IGifBlock[] getBlocks()

Gets the GIF blocks.


getHeight

public int getHeight()

Gets the object height.

Value: The object height.

Specified by:
getHeight in interface IObjectWithBounds
Specified by:
getHeight in class Image

getImageLoaderDescriptorName

public java.lang.String getImageLoaderDescriptorName()

Gets the name of the image loader descriptor.

Value: The name of the image loader descriptor.


This value is used later for proper image deserialization, thus specify valid registered descriptor here. During deserialization each descriptor type name is validated against this value.

Specified by:
getImageLoaderDescriptorName in class Image

getWidth

public int getWidth()

Gets the object width.

Value: The object width.

Specified by:
getWidth in interface IObjectWithBounds
Specified by:
getWidth in class Image

hasTrailer

public boolean hasTrailer()

Gets a value indicating whether GIF has trailer.

Value: true if GIF has trailer; otherwise, false.


hasTrailer

public void hasTrailer(boolean value)

Sets a value indicating whether GIF has trailer.

Value: true if GIF has trailer; otherwise, false.


onPaletteChanged

protected void onPaletteChanged(IColorPalette oldPalette,
                                IColorPalette newPalette)

Called when palette is changed.

Overrides:
onPaletteChanged in class Image
Parameters:
oldPalette - The old palette.
newPalette - The new palette.

onPaletteChanging

protected void onPaletteChanging(IColorPalette oldPalette,
                                 IColorPalette newPalette)

Called when palette is changing.

Overrides:
onPaletteChanging in class Image
Parameters:
oldPalette - The old palette.
newPalette - The new palette.

orderBlocks

public void orderBlocks()

Orders the GIF blocks according to the GIF specification. Some GifGraphicsControlBlock may be removed for proper GIF layout.


releaseManagedResources

protected void releaseManagedResources()

Releases the managed resources. Make sure no unmanaged resources are released here, since they may have been already released.

Overrides:
releaseManagedResources in class RasterImage

removeBlock

public void removeBlock(IGifBlock block)

Removes the GIF block.

Parameters:
block - The block to remove.


Note: do not forget to Dispose the block if you will not add it to some other GifImage.


resize

public void resize(int newWidth,
                   int newHeight,
                   int resizeType)

Resizes the image.

Overrides:
resize in class RasterImage
Parameters:
newWidth - The new width.
newHeight - The new height.
resizeType - The resize type.

setActiveFrame

public void setActiveFrame(GifFrameBlock value)

Sets the active frame.

Value: The active frame.


setBackgroundColor

public void setBackgroundColor(Color value)

Sets the background color.

Value: The background color.


setBackgroundColorIndex

public void setBackgroundColorIndex(byte value)

Sets the background color index.

Value: The background color index.