public abstract class ImageOptionsBase extends DisposableObject
The image base options.
Modifier and Type | Method and Description |
---|---|
ImageOptionsBase |
deepClone()
Clones this instance.
|
int |
getBufferSizeHint()
Gets the buffer size hint which is defined max allowed size for all internal buffers.
|
MultiPageOptions |
getMultiPageOptions()
The multipage options
|
IColorPalette |
getPalette()
Gets the color palette.
|
ProgressEventHandler |
getProgressEventHandler()
Gets the progress event handler.
|
ResolutionSetting |
getResolutionSettings()
Gets the resolution settings.
|
Source |
getSource()
Gets the source to create image in.
|
VectorRasterizationOptions |
getVectorRasterizationOptions()
Gets the vector rasterization options.
|
XmpPacketWrapper |
getXmpData()
Gets the XMP metadata container.
|
void |
setBufferSizeHint(int value)
Sets the buffer size hint which is defined max allowed size for all internal buffers.
|
void |
setMultiPageOptions(MultiPageOptions value)
The multipage options
|
void |
setPalette(IColorPalette value)
Sets the color palette.
|
void |
setProgressEventHandler(ProgressEventHandler value)
Sets the progress event handler.
|
void |
setResolutionSettings(ResolutionSetting value)
Sets the resolution settings.
|
void |
setSource(Source value)
Gets or sets the source to create image in.
|
void |
setVectorRasterizationOptions(VectorRasterizationOptions value)
Sets the vector rasterization options.
|
void |
setXmpData(XmpPacketWrapper value)
Sets the XMP metadata container.
|
close, dispose, getDisposed
public XmpPacketWrapper getXmpData()
Gets the XMP metadata container.
public void setXmpData(XmpPacketWrapper value)
Sets the XMP metadata container.
value
- The XMP data container.public Source getSource()
Gets the source to create image in.
public void setSource(Source value)
Gets or sets the source to create image in.
value
- The source to create image in.public IColorPalette getPalette()
Gets the color palette.
public void setPalette(IColorPalette value)
Sets the color palette.
value
- The color palette.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.
public ResolutionSetting getResolutionSettings()
Gets the resolution settings.
public void setResolutionSettings(ResolutionSetting value)
Sets the resolution settings.
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(); }
public VectorRasterizationOptions getVectorRasterizationOptions()
Gets the vector rasterization options.
public void setVectorRasterizationOptions(VectorRasterizationOptions value)
Sets the vector rasterization options.
value
- The vector rasterization options.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 bufferspublic 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 buffersvalue
- the buffer size hint which is defined max allowed size for all internal buffers.public MultiPageOptions getMultiPageOptions()
The multipage options
public void setMultiPageOptions(MultiPageOptions value)
The multipage options
public ProgressEventHandler getProgressEventHandler()
Gets the progress event handler.
Value: The progress event handler.public void setProgressEventHandler(ProgressEventHandler value)
Sets the progress event handler.
Value: The progress event handler.value
- the progress event handler.The following example shows how to print information about progress events for load/export operations.
String dir = "c:\\aspose.imaging\\java\\issues\\1440\\"; String fileName = dir + "big.png"; // Example of use of separate operation progress event handlers for load/export operations final com.aspose.imaging.ProgressEventHandler loadHandler = new com.aspose.imaging.ProgressEventHandler() { @Override public void invoke(com.aspose.imaging.progressmanagement.ProgressEventHandlerInfo info) { System.out.format("Load event %s : %d/%d\n", com.aspose.imaging.progressmanagement.EventType.toString(com.aspose.imaging.progressmanagement.EventType.class, info.getEventType()), info.getValue(), info.getMaxValue()); } }; final com.aspose.imaging.ProgressEventHandler exportHandler = new com.aspose.imaging.ProgressEventHandler() { @Override public void invoke(com.aspose.imaging.progressmanagement.ProgressEventHandlerInfo info) { System.out.format("Export event %s : %d/%d\n", com.aspose.imaging.progressmanagement.EventType.toString(com.aspose.imaging.progressmanagement.EventType.class, info.getEventType()), info.getValue(), info.getMaxValue()); } }; com.aspose.imaging.Image image = com.aspose.imaging.Image.load(fileName, new com.aspose.imaging.LoadOptions() {{ setProgressEventHandler(loadHandler); }} ); try { image.save(fileName + ".psd", new com.aspose.imaging.imageoptions.PsdOptions() {{ setProgressEventHandler( exportHandler); }}); } finally { image.close(); } // The STDOUT log may look like this: // Load event Initialization : 1/4 // Load event PreProcessing : 2/4 // Load event Processing : 3/4 // Load event Finalization : 4/4 // Export event Initialization : 1/4 // Export event PreProcessing : 2/4 // Export event Processing : 3/4 // Export event RelativeProgress : 1/1 // Load event RelativeProgress : 1/1 // Export event Finalization : 4/4
public ImageOptionsBase deepClone()
Clones this instance.