Packages

 

com.aspose.imaging

Interfaces

Classes

com.aspose.imaging

Class Image

    • Method Detail

      • canLoad

        public static boolean canLoad(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(String filePath,
                                      LoadOptions 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.
      • canLoad

        public static boolean canLoad(InputStream stream)

        Determines whether image can be loaded from the specified stream.

        Parameters:
        stream - The stream to load from.
        Returns:
        true if image can be loaded from the specified stream; otherwise, false.
      • canLoad

        public static boolean canLoad(InputStream stream,
                                      LoadOptions loadOptions)

        Determines whether image can be loaded from the specified stream and optionally using the specified loadOptions.

        Parameters:
        stream - The stream to load from.
        loadOptions - The load options.
        Returns:
        true if image can be loaded from the specified stream; otherwise, false.
      • create

        public static Image create(ImageOptionsBase imageOptions,
                                   int width,
                                   int height)

        Creates a new image using the specified create options.

        Parameters:
        imageOptions - The image options.
        width - The width.
        height - The height.
        Returns:
        The newly created image.
      • getFileFormat

        public static long getFileFormat(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.
      • getFileFormat

        public static long getFileFormat(InputStream stream)

        Gets the file format.

        Parameters:
        stream - The stream.

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

        Returns:
        The determined file format.
      • 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.
      • getFittingRectangle

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

        Gets rectangle which fits the current image.

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

        public static Image load(String filePath,
                                 LoadOptions loadOptions)

        Loads a new image from the specified file.

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

        public static Image load(String filePath)

        Loads a new image from the specified file.

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

        public static Image load(RandomAccessFile file,
                                 LoadOptions loadOptions)

        Loads a new image from the specified stream.

        Parameters:
        file - The file to load image from.
        loadOptions - The load options.
        Returns:
        The loaded image.
      • load

        public static Image load(RandomAccessFile file)

        Loads a new image from the specified stream.

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

        public static Image load(InputStream stream,
                                 LoadOptions loadOptions)

        Loads a new image from the specified stream.

        Parameters:
        stream - The stream to load image from.
        loadOptions - The load options.
        Returns:
        The loaded image.
      • load

        public static Image load(InputStream stream)

        Loads a new image from the specified stream.

        Parameters:
        stream - The stream to load image from.
        Returns:
        The loaded image.
      • getProportionalWidth

        public static int getProportionalWidth(int width,
                                               int height,
                                               int newHeight)

        Gets a proportional width.

        Parameters:
        width - The width.
        height - The height.
        newHeight - The new height.
        Returns:
        The proportional width.
      • getProportionalHeight

        public static int getProportionalHeight(int width,
                                                int height,
                                                int newWidth)

        Gets a proportional height.

        Parameters:
        width - The width.
        height - The height.
        newWidth - The new width.
        Returns:
        The proportional height.
      • getBitsPerPixel

        public abstract int getBitsPerPixel()

        Gets the image bits per pixel count.

        Returns:
        The image bits per pixel count.
      • 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.

      • getHeight

        public abstract int getHeight()

        Gets the image height.

        Specified by:
        getHeight in interface IObjectWithBounds
        Returns:
        The image height.
      • getPalette

        public IColorPalette getPalette()

        Gets the color palette.

        Returns:
        The color palette.
      • setPalette

        public void setPalette(IColorPalette value)

        Sets the color palette.

        Parameters:
        value - The color palette.
      • getWidth

        public abstract int getWidth()

        Gets the image width.

        Specified by:
        getWidth in interface IObjectWithBounds
        Returns:
        The image width.
      • getInterruptMonitor

        public InterruptMonitor getInterruptMonitor()

        Gets the interrupt monitor.

        Returns:
        the interrupt monitor.
      • setInterruptMonitor

        public void setInterruptMonitor(InterruptMonitor value)

        Sets the interrupt monitor.

        Parameters:
        value - the interrupt monitor.
      • getBufferSizeHint

        public final int getBufferSizeHint()

        Gets the buffer size hint which is defined max allowed size for all internal buffers.

        Value: The buffer size hint, in megabytes. Non-positive value means no memory limitation for internal buffers
        Returns:
        the buffer size hint which is defined max allowed size for all internal buffers.
      • setBufferSizeHint

        public final void setBufferSizeHint(int value)

        Sets the buffer size hint which is defined max allowed size for all internal buffers.

        Value: The buffer size hint, in megabytes. Non-positive value means no memory limitation for internal buffers
        Parameters:
        value - the buffer size hint which is defined max allowed size for all internal buffers.
      • isAutoAdjustPalette

        public boolean isAutoAdjustPalette()

        Gets a value indicating whether automatic adjust palette.

        Returns:
        true if enable automatic adjust palette; otherwise, false.
      • setAutoAdjustPalette

        public void setAutoAdjustPalette(boolean value)

        Sets a value indicating whether automatic adjust palette.

        Parameters:
        value - true if enable automatic adjust palette; otherwise, false.
      • hasBackgroundColor

        public boolean hasBackgroundColor()

        Gets a value indicating whether image has background color.

      • getFileFormat

        public long getFileFormat()

        Gets a value of file format

      • getBackgroundColor

        public Color getBackgroundColor()

        Gets or sets a value for the background color.

      • setBackgroundColor

        public void setBackgroundColor(boolean value)

        Gets or sets a value indicating whether image has background color.

      • setBackgroundColor

        public void setBackgroundColor(Color value)

        Gets or sets a value for the background color.

      • canSave

        public boolean canSave(ImageOptionsBase options)

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

        Parameters:
        options - The save options to use.
        Returns:
        true if image can be saved to the specified file format represented by the passed save options; otherwise, false.
      • 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.
      • resize

        public abstract void resize(int newWidth,
                                    int newHeight,
                                    ImageResizeSettings settings)

        Resizes the image.

        Parameters:
        newWidth - The new width.
        newHeight - The new height.
        settings - The resize settings.
      • getDefaultOptions

        public ImageOptionsBase getDefaultOptions(Object[] args)

        Gets the default options.

        Parameters:
        args - The arguments.
        Returns:
        Default options
      • getOriginalOptions

        public ImageOptionsBase getOriginalOptions()

        Gets the options based on the original file settings. This can be helpful to keep bit-depth and other parameters of the original image unchanged. For example, if we load a black-white PNG image with 1 bit per pixel and then save it using the DataStreamSupporter.Save(string) method, the output PNG image with 8-bit per pixel will be produced. To avoid it and save PNG image with 1-bit per pixel, use this method to get corresponding saving options and pass them to the Image.Save(string, ImageOptionsBase) method as the second parameter.

        Returns:
        The options based on the original file settings.
      • resizeWidthProportionally

        public void resizeWidthProportionally(int newWidth)

        Resizes the width proportionally.

        Parameters:
        newWidth - The new width.
      • resizeHeightProportionally

        public void resizeHeightProportionally(int newHeight)

        Resizes the height proportionally.

        Parameters:
        newHeight - The new height.
      • resizeWidthProportionally

        public void resizeWidthProportionally(int newWidth,
                                              int resizeType)

        Resizes the width proportionally.

        Parameters:
        newWidth - The new width.
        resizeType - Type of the resize.
      • resizeHeightProportionally

        public void resizeHeightProportionally(int newHeight,
                                               int resizeType)

        Resizes the height proportionally.

        Parameters:
        newHeight - The new height.
        resizeType - Type of the resize.
      • resizeWidthProportionally

        public void resizeWidthProportionally(int newWidth,
                                              ImageResizeSettings settings)

        Resizes the width proportionally.

        Parameters:
        newWidth - The new width.
        settings - The image resize settings.
      • resizeHeightProportionally

        public void resizeHeightProportionally(int newHeight,
                                               ImageResizeSettings settings)

        Resizes the height proportionally.

        Parameters:
        newHeight - The new height.
        settings - The image resize settings.
      • rotateFlip

        public abstract void rotateFlip(int rotateFlipType)

        Rotates, flips, or rotates and flips the image.

        Parameters:
        rotateFlipType - Type of the rotate flip.
      • save

        public final void save()

        Saves the image data to the underlying stream.

        Overrides:
        save in class DataStreamSupporter
      • save

        public void save(String filePath,
                         ImageOptionsBase options)

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

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

        public void save(String filePath,
                         ImageOptionsBase options,
                         Rectangle boundsRectangle)

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

        Parameters:
        filePath - The file path.
        options - The options.
        boundsRectangle - The destination image bounds rectangle. Set the empty rectangle for use sourse bounds.
        Throws:
        com.aspose.ms.System.ArgumentNullException - options
        ImageSaveException - Image saving failed.
      • save

        public void save(RandomAccessFile file,
                         ImageOptionsBase options)

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

        Parameters:
        file - The file to save the image's data to.
        options - The options.
      • save

        public void save(RandomAccessFile file,
                         ImageOptionsBase optionsBase,
                         Rectangle boundsRectangle)

        Saves the image's data to the specified stream in the specified file format according to save options.

        Parameters:
        file - The file to save the image's data to.
        optionsBase - The save options.
        boundsRectangle - The destination image bounds rectangle. Set the empty rectangle for use sourse bounds.
        Throws:
        com.aspose.ms.System.ArgumentNullException - optionsBase
        com.aspose.ms.System.ArgumentException - Cannot save to the specified format as it is not supported at the moment.;optionsBase
        ImageSaveException - Image export failed.
      • save

        public void save(OutputStream stream,
                         ImageOptionsBase optionsBase)

        Saves the image's data to the specified stream in the specified file format according to save options.

        Parameters:
        stream - The stream to save the image's data to.
        optionsBase - The save options.
        Throws:
        com.aspose.ms.System.ArgumentNullException - optionsBase
        com.aspose.ms.System.ArgumentException - Cannot save to the specified format as it is not supported at the moment.;optionsBase
        ImageSaveException - Image export failed.
      • save

        public void save(OutputStream stream,
                         ImageOptionsBase optionsBase,
                         Rectangle boundsRectangle)

        Saves the image's data to the specified stream in the specified file format according to save options.

        Parameters:
        stream - The stream to save the image's data to.
        optionsBase - The save options.
        boundsRectangle - The destination image bounds rectangle. Set the empty rectangle for use sourse bounds.
        Throws:
        com.aspose.ms.System.ArgumentNullException - optionsBase
        com.aspose.ms.System.ArgumentException - Cannot save to the specified format as it is not supported at the moment.;optionsBase
        ImageSaveException - Image export failed.
      • 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.