Packages

 

com.aspose.psd

Interfaces

Classes

Exceptions

com.aspose.psd

Class ProgressEventHandler

  • java.lang.Object
    • com.aspose.ms.System.Delegate
      • com.aspose.ms.System.MulticastDelegate
        • com.aspose.psd.ProgressEventHandler


  • public abstract class ProgressEventHandler
    extends com.aspose.ms.System.MulticastDelegate

    Progress event handler function reference

    Code example:

    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 Detail

      • ProgressEventHandler

        public ProgressEventHandler()
    • Method Detail

      • invoke

        public abstract void invoke(ProgressEventHandlerInfo info)

        Progress event handler function reference

        Parameters:
        info - The progress event handler data.
      • beginInvoke

        public final com.aspose.ms.System.IAsyncResult beginInvoke(ProgressEventHandlerInfo info,
                                                                   com.aspose.ms.System.AsyncCallback callback,
                                                                   Object state)
      • endInvoke

        public final void endInvoke(com.aspose.ms.System.IAsyncResult result)