DisposableObject

Inheritance: java.lang.Object

All Implemented Interfaces: com.aspose.ms.System.IDisposable, java.io.Closeable

public class DisposableObject implements System.IDisposable, Closeable

Represents disposable object.

Constructors

ConstructorDescription
DisposableObject()

Methods

MethodDescription
getDisposed()Gets a value indicating whether this instance is disposed.
close()Implements the Closable interface and can be used in the try-with-resources statement since JDK 1.7.
dispose()Disposes the current instance.

DisposableObject()

public DisposableObject()

getDisposed()

public final boolean getDisposed()

Gets a value indicating whether this instance is disposed.

Returns: boolean - true if disposed; otherwise, false.

close()

public void close()

Implements the Closable interface and can be used in the try-with-resources statement since JDK 1.7. This method simply call dispose method.

dispose()

public void dispose()

Disposes the current instance.

Example: The following example shows how to compose a mutlipage TIFF from individual raster images.


com.aspose.imaging.imageoptions.TiffOptions createTiffOptions
        = new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default);
createTiffOptions.setSource(new com.aspose.imaging.sources.FileCreateSource("c:\\temp\\multipage.tif", false));
createTiffOptions.setPhotometric(com.aspose.imaging.fileformats.tiff.enums.TiffPhotometrics.Rgb);
createTiffOptions.setBitsPerSample(new int[]{8, 8, 8});

com.aspose.imaging.fileformats.tiff.TiffImage tiffImage = (com.aspose.imaging.fileformats.tiff.TiffImage) com.aspose.imaging.Image.create(createTiffOptions, 100, 100);
try {
    // This is Font and Brush for drawing text on individual frames.
    com.aspose.imaging.Font font = new com.aspose.imaging.Font("Arial", 64);
    com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getWhite());

    // Create 5 frames
    for (int i = 1; i <= 5; i++) {
        com.aspose.imaging.imageoptions.PngOptions createPngOptions = new com.aspose.imaging.imageoptions.PngOptions();
        createPngOptions.setSource(new com.aspose.imaging.sources.StreamSource(new java.io.ByteArrayInputStream(new byte[0])));

        // Create a PNG image and draw the number of page on it.
        com.aspose.imaging.fileformats.png.PngImage pngImage = (com.aspose.imaging.fileformats.png.PngImage) com.aspose.imaging.Image.create(createPngOptions, 100, 100);
        com.aspose.imaging.Graphics gr = new com.aspose.imaging.Graphics(pngImage);
        gr.drawString(Integer.toString(i), font, brush, 10, 10);

        // Create a frame based on the PNG image.
        com.aspose.imaging.fileformats.tiff.TiffFrame frame = new com.aspose.imaging.fileformats.tiff.TiffFrame(pngImage);

        // Add the frame to the TIFF image.
        tiffImage.addFrame(frame);
    }

    // The image was created with a single default frame. Let's remove it.
    com.aspose.imaging.fileformats.tiff.TiffFrame activeFrame = tiffImage.getActiveFrame();
    tiffImage.setActiveFrame(tiffImage.getFrames()[1]);
    tiffImage.removeFrame(0);

    // Don't forget to dispose the frame if you won't add it to some other TiffImage
    activeFrame.dispose();

    tiffImage.save();
} finally {
    tiffImage.dispose();
}