com.aspose.imaging
Class Image

java.lang.Object
  extended by com.aspose.imaging.DisposableObject
      extended by com.aspose.imaging.DataStreamSupporter
          extended by com.aspose.imaging.Image
All Implemented Interfaces:
IObjectWithBounds
Direct Known Subclasses:
RasterImage

public abstract class Image
extends DataStreamSupporter
implements IObjectWithBounds

The image is the base class for all type of images.


Constructor Summary
protected Image()
           Initializes a new instance of the Image class.
protected Image(IColorPalette colorPalette, boolean useCompactPalette)
           Initializes a new instance of the Image class.
 
Method Summary
static boolean canLoad(java.io.InputStream stream)
           
static boolean canLoad(java.io.InputStream stream, LoadOptionsBase loadOptions)
           
static boolean canLoad(java.lang.String filePath)
           Determines whether image can be loaded from the specified file path.
static boolean canLoad(java.lang.String filePath, LoadOptionsBase loadOptions)
           Determines whether image can be loaded from the specified file path and optionally using the specified open options.
 boolean canSave(SaveOptionsBase saveOptions)
           Determines whether image can be saved to the specified file format represented by the passed save options.
static Image create(ImageCreateOptions imageCreateOptions)
           Creates a new image using the specified create options.
abstract  int getBitsPerPixel()
           Gets the image bits per pixel count.
 Rectangle getBounds()
           Gets the image bounds.
 Image getContainer()
           Gets the Image container.
static long getFileFormat(java.io.InputStream stream)
           Gets the file format.
static long getFileFormat(java.lang.String filePath)
           Gets the file format.
protected  Rectangle getFitRectangle(Rectangle rectangle)
           Gets rectangle which fits the current image.
protected  Rectangle getFitRectangle(Rectangle rectangle, Color[] pixels)
           Gets rectangle which fits the current bitmap taking into account the pixels passed.
static Rectangle getFittingRectangle(Rectangle rectangle, Color[] pixels, int width, int height)
           Gets rectangle which fits the current image.
static Rectangle getFittingRectangle(Rectangle rectangle, int width, int height)
           Gets rectangle which fits the current image.
abstract  int getHeight()
           Gets the image height.
abstract  java.lang.String getImageLoaderDescriptorName()
           Gets the name of the image loader descriptor.
 IColorPalette getPalette()
           Gets or sets the color palette.
 Size getSize()
           Gets the image size.
 boolean getUseCompactPalette()
           Gets or sets a value indicating whether compact palette is used.
abstract  int getWidth()
           Gets the image width.
static Image load(java.io.InputStream stream)
           Loads a new image from the InputStream.
static Image load(java.lang.String filePath)
           Loads a new image from the specified file.
protected  void onCompactPaletteUsageChanged()
           Called when compact palette usage is changed.
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 resize(int newWidth, int newHeight)
           Resizes the image.
abstract  void resize(int newWidth, int newHeight, int resizeType)
           Resizes the image.
abstract  void rotateFlip(int rotateFlipType)
           Rotates, flips, or rotates and flips the image.
 void save(java.io.InputStream stream, SaveOptionsBase saveOptions)
           
 void save(java.io.OutputStream stream)
           
 void save(java.lang.String filePath, SaveOptionsBase saveOptions)
           Saves the object's data to the specified file location in the specified file format according to save options.
 void setContainer(Image container)
           Sets the Image container.
 void setPalette(IColorPalette value)
           
abstract  void setPalette(IColorPalette palette, boolean updateColors)
           Sets the image palette.
 void setUseCompactPalette(boolean value)
           
 
Methods inherited from class com.aspose.imaging.DataStreamSupporter
flush, getDataStreamContainer, onDataStreamContainerChanging, releaseManagedResources, 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

Image

protected Image()

Initializes a new instance of the Image class.


Image

protected Image(IColorPalette colorPalette,
                boolean useCompactPalette)

Initializes a new instance of the Image class.

Parameters:
colorPalette - The color palette.
useCompactPalette - if set to true compact palette is used.
Method Detail

canLoad

public static boolean canLoad(java.io.InputStream stream)

canLoad

public static boolean canLoad(java.io.InputStream stream,
                              LoadOptionsBase loadOptions)

canLoad

public static boolean canLoad(java.lang.String filePath)

Determines whether image can be loaded from the specified file path.

Parameters:
filePath - The file path.
Returns:
true if image can be loaded from the specified file; otherwise, false.

canLoad

public static boolean canLoad(java.lang.String filePath,
                              LoadOptionsBase loadOptions)

Determines whether image can be loaded from the specified file path and optionally using the specified open options.

Parameters:
filePath - The file path.
loadOptions - The load options.
Returns:
true if image can be loaded from the specified file; otherwise, false.

canSave

public boolean canSave(SaveOptionsBase saveOptions)

Determines whether image can be saved to the specified file format represented by the passed save options.


create

public static Image create(ImageCreateOptions imageCreateOptions)

Creates a new image using the specified create options.

Parameters:
imageCreateOptions - The image create options.
Returns:
The newly created image.

getBitsPerPixel

public abstract int getBitsPerPixel()

Gets the image bits per pixel count.

Value: The image bits per pixel count.


getBounds

public Rectangle getBounds()

Gets the image bounds.

Value: The image bounds.

Specified by:
getBounds in interface IObjectWithBounds

getContainer

public Image getContainer()

Gets the Image container.

Value: The Image container.


If this property is not null it indicates the image is contained whithin another image.


getFileFormat

public static long getFileFormat(java.io.InputStream stream)

Gets the file format.

Parameters:
stream - The stream.

getFileFormat

public static long getFileFormat(java.lang.String filePath)

Gets the file format.

Parameters:
filePath - The file path.


The file format determined does not mean that the specified image may be loaded. Use one of the CanLoad method overloads to determine whether file may be loaded.

Returns:
The determined file format.

getFitRectangle

protected Rectangle getFitRectangle(Rectangle rectangle)

Gets rectangle which fits the current image.

Parameters:
rectangle - The rectangle to get fitting rectangle for.
Returns:
The fitting rectangle

getFitRectangle

protected Rectangle getFitRectangle(Rectangle rectangle,
                                    Color[] pixels)

Gets rectangle which fits the current bitmap taking into account the pixels passed. The passed pixels array count should be equal to the fitting rectangle size.

Parameters:
rectangle - The rectangle to get fitting rectangle for.
pixels - The pixels array.
Returns:
The fitting rectangle.

getFittingRectangle

public static Rectangle getFittingRectangle(Rectangle rectangle,
                                            Color[] pixels,
                                            int width,
                                            int height)

Gets rectangle which fits the current image.

Parameters:
rectangle - The rectangle to get fitting rectangle for.
pixels - The pixels.
width - The object width.
height - The object height.
Returns:
The fitting rectangle or exception if no fitting rectangle can be found.

getFittingRectangle

public static Rectangle getFittingRectangle(Rectangle rectangle,
                                            int width,
                                            int height)

Gets rectangle which fits the current image.

Parameters:
rectangle - The rectangle to get fitting rectangle for.
width - The object width.
height - The object height.
Returns:
The fitting rectangle or exception if no fitting rectangle can be found.

getHeight

public abstract int getHeight()

Gets the image height.

Value: The image height.

Specified by:
getHeight in interface IObjectWithBounds

getImageLoaderDescriptorName

public abstract 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.


getPalette

public IColorPalette getPalette()

Gets or sets the color palette.

Value: The color palette.


getSize

public Size getSize()

Gets the image size.

Value: The image size.

Specified by:
getSize in interface IObjectWithBounds

getUseCompactPalette

public boolean getUseCompactPalette()

Gets or sets a value indicating whether compact palette is used.

Value: true if compact palette is used; otherwise, false.


Compact palette means that image will contain only the specified palette entries if possible or in other words the image will be more compact and occupy less space; otherwise there will be 2^BitsPerPixel entries and image will reserve more space for all possible palette entries. Setting this value to true and changing palette entries may cause performance penalty since data movement may occur so use it carefully.


getWidth

public abstract int getWidth()

Gets the image width.

Value: The image width.

Specified by:
getWidth in interface IObjectWithBounds

load

public static Image load(java.io.InputStream stream)

Loads a new image from the InputStream.

Returns:
The loaded image.

load

public static Image load(java.lang.String filePath)

Loads a new image from the specified file.

Parameters:
filePath - The file path to load image from.
Returns:
The loaded image.

onCompactPaletteUsageChanged

protected void onCompactPaletteUsageChanged()

Called when compact palette usage is changed.


onPaletteChanged

protected void onPaletteChanged(IColorPalette oldPalette,
                                IColorPalette newPalette)

Called when palette is changed.

Parameters:
oldPalette - The old palette.
newPalette - The new palette.

onPaletteChanging

protected void onPaletteChanging(IColorPalette oldPalette,
                                 IColorPalette newPalette)

Called when palette is changing.

Parameters:
oldPalette - The old palette.
newPalette - The new palette.

resize

public void resize(int newWidth,
                   int newHeight)

Resizes the image. The default ResizeType.LeftTopToLeftTop is used.

Parameters:
newWidth - The new width.
newHeight - The new height.

resize

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

Resizes the image.

Parameters:
newWidth - The new width.
newHeight - The new height.
resizeType - The resize type.

rotateFlip

public abstract void rotateFlip(int rotateFlipType)

Rotates, flips, or rotates and flips the image.

Parameters:
rotateFlipType - Type of the rotate flip.

save

public void save(java.io.InputStream stream,
                 SaveOptionsBase saveOptions)

save

public void save(java.io.OutputStream stream)

save

public void save(java.lang.String filePath,
                 SaveOptionsBase saveOptions)

Saves the object's data to the specified file location in the specified file format according to save options.

Parameters:
filePath - The file path.
saveOptions - The save options.

setContainer

public void setContainer(Image container)

Sets the Image container.

Parameters:
container - The Image container.

setPalette

public void setPalette(IColorPalette value)

setPalette

public abstract void setPalette(IColorPalette palette,
                                boolean updateColors)

Sets the image palette.

Parameters:
palette - The palette to set.
updateColors - if set to true colors will be updated according to the new palette; otherwise color indexes remain unchanged. Note that unchanged indexes may crash the image on loading if some indexes have no corresponding palette entries.

setUseCompactPalette

public void setUseCompactPalette(boolean value)