public abstract class ProgressEventHandler
extends com.aspose.ms.System.MulticastDelegate
Progress event handler function reference
An example of usage of the progress handler for loading and saving operations. The program uses different saving options to fire progress events.
String sourceFilePath = "Apple.psd";
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
// Create a progress handler that writes progress info to the console
ProgressEventHandler localProgressEventHandler = new ProgressEventHandler()
{
@Override
public void invoke(ProgressEventHandlerInfo progressInfo)
{
String message = String.format(
"%s %s: %s out of %s",
progressInfo.getDescription(),
Enum.getName(EventType.class, progressInfo.getEventType()),
progressInfo.getValue(),
progressInfo.getMaxValue());
System.out.println(message);
}
};
System.out.println("---------- Loading Apple.psd ----------");
PsdLoadOptions loadOptions = new PsdLoadOptions();
// Bind the progress handler to show loading progress
loadOptions.setProgressEventHandler(localProgressEventHandler);
// Load PSD using specific loading options
PsdImage image = (PsdImage)Image.load(sourceFilePath, loadOptions);
try
{
System.out.println("---------- Saving Apple.psd to PNG format ----------");
PngOptions pngOptions = new PngOptions();
// Make the output image coloured and non-transparent
pngOptions.setColorType(PngColorType.Truecolor);
// Bind the progress handler to show saving progress
pngOptions.setProgressEventHandler(localProgressEventHandler);
// Convert PSD to PNG with specific characteristics
image.save(outputStream, pngOptions);
System.out.println("---------- Saving Apple.psd to PSD format ----------");
PsdOptions psdOptions = new PsdOptions();
// Make the output PSD coloured
psdOptions.setColorMode(ColorModes.Rgb);
// Set a channel for each color (red, green, and blue) plus a composite channel
psdOptions.setChannelsCount((short)4);
// Bind the progress handler to show saving progress
psdOptions.setProgressEventHandler(localProgressEventHandler);
// Save a copy of PSD with specific characteristics
image.save(outputStream, psdOptions);
}
finally
{
image.dispose();
}
| Constructor and Description |
|---|
ProgressEventHandler() |
| Modifier and Type | Method and Description |
|---|---|
com.aspose.ms.System.IAsyncResult |
beginInvoke(ProgressEventHandlerInfo info,
com.aspose.ms.System.AsyncCallback callback,
Object state) |
void |
endInvoke(com.aspose.ms.System.IAsyncResult result) |
abstract void |
invoke(ProgressEventHandlerInfo info)
Progress event handler function reference
|
public abstract void invoke(ProgressEventHandlerInfo info)
Progress event handler function reference
info - The progress event handler data.public final com.aspose.ms.System.IAsyncResult beginInvoke(ProgressEventHandlerInfo info, com.aspose.ms.System.AsyncCallback callback, Object state)
public final void endInvoke(com.aspose.ms.System.IAsyncResult result)
Copyright (c) 2008-2020 Aspose Pty Ltd. All Rights Reserved.