Skip to main content

DXImage Class

Serves as the base class for image objects.

Declaration

public abstract class DXImage extends JavaObject implements IDisposable, IEquatable<DXImage>

Remarks

The following code snippet exports all pages of a PDF document to DXImage objects and saves each page as a separate PNG image:

import com.devexpress.drawing.*;
import com.devexpress.docs.pdf.*;

import java.nio.channels.*;
import java.nio.file.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (PdfDocument pdfDocument =
                 new PdfDocument(FileChannel.open(Path.of("document.pdf")))) {

            // Export all pages to images.
            int pageCount = pdfDocument.getPages().size();
            int[] pageIndexes = new int[pageCount];
            for (int i = 0; i < pageCount; i++) {
                pageIndexes[i] = i;
            }

            DXImage[] images = pdfDocument.exportToImages(pageIndexes);

            try {
                // Save each page as a PNG image.
                for (int i = 0; i < images.length; i++) {
                    images[i].save(
                        "page-" + (i + 1) + ".png",
                        DXImageFormat.getPng());
                }
            } finally {
                // Release image resources.
                for (DXImage image : images) {
                    image.close();
                }
            }
        }
    }
}

Implements

com.devexpress.system.IDisposable
com.devexpress.system.IEquatable<com.devexpress.drawing.DXImage>

Inherited Members

com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.initFields()
com.devexpress.system.JavaObject.memberwiseClone()
com.devexpress.system.JavaObject.toString()
java.lang.Object.finalize()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Inheritance

Object
com.devexpress.system.JavaObject
DXImage

Methods

clone() Method

Creates a copy of this image.

Declaration

public abstract DXImage clone()

Returns

Type Description
DXImage

The cloned DXImage object.

close() Method

Releases resources used by this image.

Declaration

public void close()

equals(DXImage other) Method

Checks whether this image equals the specified image.

Declaration

public boolean equals(DXImage other)

Parameters

Name Type Description
other DXImage

The image to compare with this image.

Returns

Type Description
boolean

true if the images are equal; otherwise, false.

fromBase64String(String base64) Method

Creates a DXImage object from the specified Base64 string.

Declaration

public static DXImage fromBase64String(String base64)

Parameters

Name Type Description
base64 String

A Base64 string that contains image data.

Returns

Type Description
DXImage

The created DXImage object.

fromChannel(ReadableByteChannel channel) Method

Creates a DXImage object from the specified channel.

Declaration

public static DXImage fromChannel(ReadableByteChannel channel)

Parameters

Name Type Description
channel ReadableByteChannel

A readable channel that contains image data.

Returns

Type Description
DXImage

The created DXImage object.

fromStream(InputStream stream) Method

Creates a DXImage object from the specified stream.

Declaration

public static DXImage fromStream(InputStream stream)

Parameters

Name Type Description
stream InputStream

An input stream that contains image data.

Returns

Type Description
DXImage

The created DXImage object.

getHeight() Method

Returns the image height.

Declaration

public int getHeight()

Returns

Type Description
int

The image height, in pixels.

getHorizontalResolution() Method

Returns the horizontal resolution.

Declaration

public float getHorizontalResolution()

Returns

Type Description
float

The horizontal resolution, in dots per inch.

getImageFormat() Method

Returns the image format.

Declaration

public DXImageFormat getImageFormat()

Returns

Type Description
DXImageFormat

The DXImageFormat object that identifies the image format.

getSize() Method

Returns the image size.

Declaration

public Size getSize()

Returns

Type Description
Size

The image size.

getVerticalResolution() Method

Returns the vertical resolution.

Declaration

public float getVerticalResolution()

Returns

Type Description
float

The vertical resolution, in dots per inch.

getWidth() Method

Returns the image width.

Declaration

public int getWidth()

Returns

Type Description
int

The image width, in pixels.

rotateFlip(DXRotateFlipType rotateFlipType) Method

Rotates and flips this image.

Declaration

public abstract void rotateFlip(DXRotateFlipType rotateFlipType)

Parameters

Name Type Description
rotateFlipType DXRotateFlipType

A DXRotateFlipType object that specifies the rotation and flip operation.

save(OutputStream stream, DXImageFormat imageFormat) Method

Saves this image to the specified stream in the specified format.

Declaration

public void save(OutputStream stream, DXImageFormat imageFormat)

Parameters

Name Type Description
stream OutputStream

The destination output stream.

imageFormat DXImageFormat

The image format to use.

save(OutputStream stream) Method

Saves this image to the specified stream.

Declaration

public void save(OutputStream stream)

Parameters

Name Type Description
stream OutputStream

The destination output stream.

save(String fileName, DXImageFormat imageFormat) Method

Saves this image to the specified file in the specified format.

Declaration

public void save(String fileName, DXImageFormat imageFormat)

Parameters

Name Type Description
fileName String

The destination file name.

imageFormat DXImageFormat

The image format to use.

save(String fileName) Method

Saves this image to the specified file.

Declaration

public void save(String fileName)

Parameters

Name Type Description
fileName String

The destination file name.

save(WritableByteChannel channel, DXImageFormat imageFormat) Method

Saves this image to the specified channel in the specified format.

Declaration

public void save(WritableByteChannel channel, DXImageFormat imageFormat)

Parameters

Name Type Description
channel WritableByteChannel

The destination writable channel.

imageFormat DXImageFormat

The image format to use.

save(WritableByteChannel channel) Method

Saves this image to the specified channel.

Declaration

public void save(WritableByteChannel channel)

Parameters

Name Type Description
channel WritableByteChannel

The destination writable channel.