public abstract class ALcdImagingEngine extends Object implements ILcdDisposable
ALcdBasicImage
.
factory methods
.
An imaging engine should be considered a heavy-weight object. It can hold system resources that are expensive to initialize
or of which there are only a limited amount available. So an application should typically re-use a single engine
multiple times. It should not create a engine for each individual processing request. Note that care should also be
taken to dispose
the engine when it is no longer needed.
ALcdImagingEngine engine = ALcdImagingEngine.createEngine();
try {
ALcdBasicImage input1 = ...;
ALcdBasicImage input2 = ...;
ALcdBasicImage output = (ALcdBasicImage) TLcdBinaryOp.binaryOp(input1, input2, ADD);
Rectangle region = output.getConfiguration().getTilePixelBounds(0, 0);
Raster outputData = engine.getImageDataReadOnly(output, region);
float[] pixel = new float[1]; // Assuming a single band image with float pixel data
for (int y=0; y < region.height; y++) {
for (int x=0; x < region.width; x++) {
outputData.getPixel(outputData.getMinX() + x, outputData.getMinY() + y, pixel);
System.out.println("Pixel at " + x + "," + y + ":" + pixel[0]);
}
}
}
finally {
engine.dispose();
}
Instances of this class are thread-safe.Modifier and Type | Class and Description |
---|---|
static class |
ALcdImagingEngine.Descriptor
Describes the capabilities and execution environment of an
ALcdImagingEngine.
|
Modifier | Constructor and Description |
---|---|
protected |
ALcdImagingEngine()
This class is not intended to be implemented by users.
|
Modifier and Type | Method and Description |
---|---|
abstract ColorModel |
createCompatibleColorModel(ALcdBasicImage aImage)
Creates a
ColorModel that is compatible with the specified image. |
protected abstract SampleModel |
createCompatibleSampleModel(ALcdBasicImage aImage,
int aWidth,
int aHeight)
Creates a
SampleModel that is compatible with the specified image. |
abstract WritableRaster |
createCompatibleWritableRaster(ALcdBasicImage aImage,
Rectangle aRegion)
Creates a
WritableRaster that is compatible with the specified image. |
static ALcdImagingEngine |
createEngine()
Creates a new imaging engine.
|
static ALcdImagingEngine |
createEngine(ALcdImagingEngine.Descriptor aDescriptor)
Creates a new imaging engine based on the given descriptor.
|
abstract BufferedImage |
getBufferedImage(ALcdBasicImage aImage,
Rectangle aRegion)
Reads a rectangular block of data out of a given image.
|
abstract ALcdImagingEngine.Descriptor |
getDescriptor()
Returns the descriptor of this imaging engine.
|
static Collection<ALcdImagingEngine.Descriptor> |
getEngineDescriptors()
Enumerates all available imaging engine implementations.
|
abstract WritableRaster |
getImageData(ALcdBasicImage aImage,
Rectangle aRegion)
Reads a rectangular block of data out of a given image.
|
abstract void |
getImageData(ALcdBasicImage aImage,
WritableRaster aOutputRasterSFCT)
Reads a rectangular block from a given image into a given raster.
|
abstract Raster |
getImageDataReadOnly(ALcdBasicImage aImage,
Rectangle aRegion)
Reads a rectangular block of data out of a given image.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, dispose
protected ALcdImagingEngine()
public static ALcdImagingEngine createEngine()
specific descriptor
.public static ALcdImagingEngine createEngine(ALcdImagingEngine.Descriptor aDescriptor)
getEngineDescriptors()
.aDescriptor
- the engine descriptorpublic static Collection<ALcdImagingEngine.Descriptor> getEngineDescriptors()
createEngine(ALcdImagingEngine.Descriptor)
public abstract WritableRaster createCompatibleWritableRaster(ALcdBasicImage aImage, Rectangle aRegion)
WritableRaster
that is compatible with the specified image.
The raster can be used with getImageData(ALcdBasicImage, java.awt.image.WritableRaster)
.aImage
- the imageaRegion
- the rectangleprotected abstract SampleModel createCompatibleSampleModel(ALcdBasicImage aImage, int aWidth, int aHeight)
SampleModel
that is compatible with the specified image.aImage
- the imageaWidth
- the width of the sample modelaHeight
- the height of the sample modelpublic abstract ColorModel createCompatibleColorModel(ALcdBasicImage aImage)
ColorModel
that is compatible with the specified image.
The result is null
if the image pixels do not represent a color
. The color model can for example be used to
create a BufferedImage
. It is also required when getting one
from the imaging engine.aImage
- the imagenull
createCompatibleWritableRaster(ALcdBasicImage, java.awt.Rectangle)
,
getBufferedImage(ALcdBasicImage, java.awt.Rectangle)
public abstract BufferedImage getBufferedImage(ALcdBasicImage aImage, Rectangle aRegion)
getImageData(ALcdBasicImage, java.awt.Rectangle)
. It can be
used in cases where an image is easier to work with than a WritableRaster
(e.g. when performing Graphics2D
operations).
Note that this method can only be used with an image that contains color
data.aImage
- the imageaRegion
- the requested regionIllegalArgumentException
- if the region is invalid, the image does not contain color data or the image is not supportedcreateCompatibleColorModel(ALcdBasicImage)
public abstract Raster getImageDataReadOnly(ALcdBasicImage aImage, Rectangle aRegion)
getImageData(com.luciad.imaging.ALcdBasicImage, java.awt.Rectangle)
,
especially if no processing is necessary to produce the data. To benefit from this performance improvement,
the requested region must coincide with a tile in the image. You can compute the region for a tile using
ALcdBasicImage.Configuration.getTilePixelBounds(int, int)
.aImage
- the imageaRegion
- the requested regionIllegalArgumentException
- if the region is invalid or the image is not supportedgetImageData(ALcdBasicImage, java.awt.Rectangle)
public abstract WritableRaster getImageData(ALcdBasicImage aImage, Rectangle aRegion)
aImage
- the imageaRegion
- the requested regionIllegalArgumentException
- if the region is invalid or the image is not supportedgetImageDataReadOnly(ALcdBasicImage, java.awt.Rectangle)
public abstract void getImageData(ALcdBasicImage aImage, WritableRaster aOutputRasterSFCT)
aOutputRasterSFCT
also indicates which block of data from
the image should be copied to it.aImage
- the imageaOutputRasterSFCT
- the raster to write the result intoIllegalArgumentException
- if the output raster is invalid or the image is not supportedcreateCompatibleWritableRaster(ALcdBasicImage, java.awt.Rectangle)
public abstract ALcdImagingEngine.Descriptor getDescriptor()