public class LoadOptions extends Object implements com.aspose.internal.progressmanagement.IProgressEventHandler
Represents the loading options.
| Constructor and Description |
|---|
LoadOptions() |
| Modifier and Type | Method and Description |
|---|---|
void |
addCustomFontSource(CustomFontSource source,
Object... args)
Adds the custom font source to supply image-specific fonts.
|
int |
getBufferSizeHint()
Gets the buffer size hint which is defined max allowed size for all internal buffers.
|
Color |
getDataBackgroundColor()
Gets the
Image background Color. |
int |
getDataRecoveryMode()
Gets the data recovery mode.
|
ProgressEventHandler |
getProgressEventHandler()
Gets the progress event handler.
|
boolean |
getUseIccProfileConversion()
Deprecated.
ICC profile conversion will be used by default and this property will be removed.
|
void |
setBufferSizeHint(int value)
Sets the buffer size hint which is defined max allowed size for all internal buffers.
|
void |
setDataBackgroundColor(Color value)
Sets the
Image background Color. |
void |
setDataRecoveryMode(int value)
Sets the data recovery mode.
|
void |
setProgressEventHandler(ProgressEventHandler value)
Sets the progress event handler.
|
void |
setUseIccProfileConversion(boolean value)
Deprecated.
ICC profile conversion will be used by default and this property will be removed.
|
public int getDataRecoveryMode()
Gets the data recovery mode.
DataRecoveryModepublic void setDataRecoveryMode(int value)
Sets the data recovery mode.
value - The data recovery mode.DataRecoveryModepublic Color getDataBackgroundColor()
Gets the Image background Color.
Typically the background color is set whenever pixel value cannot be recovered due to data corruption.
public void setDataBackgroundColor(Color value)
Sets the Image background Color.
value - The background color.
Typically the background color is set whenever pixel value cannot be recovered due to data corruption.
@Deprecated public boolean getUseIccProfileConversion()
Gets a value indicating whether ICC profile conversion should be applied.
@Deprecated public void setUseIccProfileConversion(boolean value)
Sets a value indicating whether ICC profile conversion should be applied.
public final void addCustomFontSource(CustomFontSource source, Object... args)
Adds the custom font source to supply image-specific fonts.
source - The custom font source provider function.args - The arguments.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.The following example shows how to set a memory limit when loading a JPEG image. The memory limit is the maximum allowed size (in megabytes) for all internal buffers.
String workDir = "c:\\temp\\";
// Setting a memory limit of 50 megabytes for target loaded image
com.aspose.imaging.LoadOptions loadOptions = new com.aspose.imaging.LoadOptions();
loadOptions.setBufferSizeHint(50);
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(workDir + "inputFile.jpg", loadOptions);
try {
com.aspose.imaging.imageoptions.JpegOptions jpegOptions = new com.aspose.imaging.imageoptions.JpegOptions();
jpegOptions.setCompressionType(com.aspose.imaging.fileformats.jpeg.JpegCompressionMode.Baseline);
jpegOptions.setQuality(100);
image.save(workDir + "outputFile_Baseline.jpg", jpegOptions);
jpegOptions = new com.aspose.imaging.imageoptions.JpegOptions();
jpegOptions.setCompressionType(com.aspose.imaging.fileformats.jpeg.JpegCompressionMode.Progressive);
image.save(workDir + "outputFile_Progressive.jpg", jpegOptions);
jpegOptions = new com.aspose.imaging.imageoptions.JpegOptions();
jpegOptions.setCompressionType(com.aspose.imaging.fileformats.jpeg.JpegCompressionMode.Lossless);
jpegOptions.setColorType(com.aspose.imaging.fileformats.jpeg.JpegCompressionColorMode.YCbCr);
jpegOptions.setBitsPerChannel((byte) 4);
image.save(workDir + "outputFile_Lossless.jpg", jpegOptions);
jpegOptions = new com.aspose.imaging.imageoptions.JpegOptions();
jpegOptions.setCompressionType(com.aspose.imaging.fileformats.jpeg.JpegCompressionMode.JpegLs);
jpegOptions.setJpegLsInterleaveMode(com.aspose.imaging.fileformats.jpeg.JpegLsInterleaveMode.None);
jpegOptions.setJpegLsAllowedLossyError(3);
jpegOptions.setJpegLsPreset(null);
image.save(workDir + "outputFile_JpegLs.jpg", jpegOptions);
} finally {
image.close();
}
public ProgressEventHandler getProgressEventHandler()
Gets the progress event handler.
Value: The progress event handler.getProgressEventHandler in interface com.aspose.internal.progressmanagement.IProgressEventHandlerpublic void setProgressEventHandler(ProgressEventHandler value)
Sets 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
Copyright (c) 2008-2022 Aspose Pty Ltd. All Rights Reserved.