Packages

 

com.aspose.imaging

Interfaces

Classes

com.aspose.imaging

Class ImageOptionsBase

    • Method Detail

      • getXmpData

        public XmpPacketWrapper getXmpData()

        Gets the XMP metadata container.

        Returns:
        The XMP data container.
      • setXmpData

        public void setXmpData(XmpPacketWrapper value)

        Sets the XMP metadata container.

        Parameters:
        value - The XMP data container.
      • getSource

        public Source getSource()

        Gets the source to create image in.

        Returns:
        The source to create image in.
      • setSource

        public void setSource(Source value)

        Gets or sets the source to create image in.

        Parameters:
        value - The source to create image in.
      • 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.
        Code example:

        The following example shows how to palletize a BMP image to reduce its output size.


        
        // Create a BMP image 100 x 100 px.
        com.aspose.imaging.fileformats.bmp.BmpImage bmpImage = new com.aspose.imaging.fileformats.bmp.BmpImage(100, 100);
        try {
            // The linear gradient from the left-top to the right-bottom corner of the image.
            com.aspose.imaging.brushes.LinearGradientBrush brush =
                    new com.aspose.imaging.brushes.LinearGradientBrush(
                            new com.aspose.imaging.Point(0, 0),
                            new com.aspose.imaging.Point(bmpImage.getWidth(), bmpImage.getHeight()),
                            com.aspose.imaging.Color.getRed(),
                            com.aspose.imaging.Color.getGreen());
        
            // Fill the entire image with the linear gradient brush.
            com.aspose.imaging.Graphics gr = new com.aspose.imaging.Graphics(bmpImage);
            gr.fillRectangle(brush, bmpImage.getBounds());
        
            // Get the closest 8-bit color palette which covers as many pixels as possible, so that a palettized image
            // is almost visually indistinguishable from a non-palletized one.
            com.aspose.imaging.IColorPalette palette = com.aspose.imaging.ColorPaletteHelper.getCloseImagePalette(bmpImage, 256);
        
            // 8-bit palette contains at most 256 colors.
            com.aspose.imaging.imageoptions.BmpOptions saveOptions = new com.aspose.imaging.imageoptions.BmpOptions();
            saveOptions.setPalette(palette);
            saveOptions.setBitsPerPixel(8);
        
            java.io.ByteArrayOutputStream stream = new java.io.ByteArrayOutputStream();
            try {
                bmpImage.save(stream, saveOptions);
                System.out.println("The palettized image size is " + stream.size() + " bytes.");
            } finally {
                stream.close();
            }
        
            stream = new java.io.ByteArrayOutputStream();
            try {
                bmpImage.save(stream);
                System.out.println("The non-palettized image size is " + stream.size() + " bytes.");
            } finally {
                stream.close();
            }
        } finally {
            bmpImage.dispose();
        }
        
        // The output looks like this:
        // The palettized image size is 11078 bytes.
        // The non-palettized image size is 40054 bytes.
        

      • getResolutionSettings

        public ResolutionSetting getResolutionSettings()

        Gets the resolution settings.

      • setResolutionSettings

        public void setResolutionSettings(ResolutionSetting value)

        Sets the resolution settings.

        Code example:

        The following example loads a BMP image and saves it to JPEG using various save options.


        String dir = "c:\\temp\\";
        
        // Load a BMP image from a file.
        com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.bmp");
        try {
            // Do some image processing.
        
            // Use additional options to specify the desired image parameters.
            com.aspose.imaging.imageoptions.JpegOptions saveOptions = new com.aspose.imaging.imageoptions.JpegOptions();
        
            // The number of bits per channel is 8.
            // When a palette is used, the color index is stored in the image data instead of the color itself.
            saveOptions.setBitsPerChannel((byte) 8);
        
            // Set the progressive type of compression.
            saveOptions.setCompressionType(com.aspose.imaging.fileformats.jpeg.JpegCompressionMode.Progressive);
        
            // Set the image quality. It is a value between 1 and 100.
            saveOptions.setQuality(100);
        
            // Set the horizontal/vertical resolution to 96 dots per inch.
            saveOptions.setResolutionSettings(new com.aspose.imaging.ResolutionSetting(96.0, 96.0));
            saveOptions.setResolutionUnit(com.aspose.imaging.ResolutionUnit.Inch);
        
            // If the source image is colored, it will be converted to grayscaled.
            saveOptions.setColorType(com.aspose.imaging.fileformats.jpeg.JpegCompressionColorMode.Grayscale);
        
            // Use a palette to reduce the output size.
            saveOptions.setPalette(com.aspose.imaging.ColorPaletteHelper.create8BitGrayscale(false));
        
            image.save(dir + "sample.palettized.jpg", saveOptions);
        } finally {
            image.dispose();
        }
        

      • getVectorRasterizationOptions

        public VectorRasterizationOptions getVectorRasterizationOptions()

        Gets the vector rasterization options.

        Returns:
        The vector rasterization options.
      • setVectorRasterizationOptions

        public void setVectorRasterizationOptions(VectorRasterizationOptions value)

        Sets the vector rasterization options.

        Parameters:
        value - The vector rasterization options.
      • 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.
      • getMultiPageOptions

        public MultiPageOptions getMultiPageOptions()

        The multipage options

      • setMultiPageOptions

        public void setMultiPageOptions(MultiPageOptions value)

        The multipage options

      • deepClone

        public ImageOptionsBase deepClone()

        Clones this instance.

        Returns:
        Returns shallow copy of this instance