Package de.intarsys.cwt.swt.image
Class SwtCompatibleRaster
java.lang.Object
java.awt.image.Raster
java.awt.image.WritableRaster
de.intarsys.cwt.swt.image.SwtCompatibleRaster
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
private band offset for use by native codeprotected byte[]
The image data array.protected int[]
Data offsets for each band of image data.protected int
Pixel stride of the image data contained in this Raster.protected int
Scanline stride of the image data contained in this Raster.Fields inherited from class java.awt.image.Raster
dataBuffer, height, minX, minY, numBands, numDataElements, parent, sampleModel, sampleModelTranslateX, sampleModelTranslateY, width
-
Constructor Summary
ConstructorsConstructorDescriptionSwtCompatibleRaster
(SampleModel paramSampleModel, DataBuffer paramDataBuffer, Point origin) SwtCompatibleRaster
(SampleModel paramSampleModel, DataBuffer paramDataBuffer, Rectangle aRegion, Point origin, WritableRaster paramParent) SwtCompatibleRaster
(SampleModel paramSampleModel, Point origin) -
Method Summary
Modifier and TypeMethodDescriptioncreateChild
(int x, int y, int width, int height, int x0, int y0, int[] bandList) Creates a subraster given a region of the raster.Creates a Raster with the same layout and the same width and height, and with new zeroed data arrays.createCompatibleWritableRaster
(int w, int h) Creates a Raster with the same layout but using a different width and height, and with new zeroed data arrays.createWritableChild
(int x, int y, int width, int height, int x0, int y0, int[] bandList) Creates a Writable subRaster given a region of the Raster.byte[]
getByteData
(int x, int y, int w, int h, byte[] outData) Returns a byte array of data elements from the specified rectangular region.byte[]
getByteData
(int x, int y, int w, int h, int band, byte[] outData) Returns a byte array of data elements from the specified rectangular region for the specified band.getDataElements
(int x, int y, int w, int h, Object obj) Returns an array of data elements from the specified rectangular region.getDataElements
(int actualX, int actualY, Object obj) Returns the data elements for all bands at the specified location.int
getDataOffset
(int band) Returns the data offset for the specified band.int[]
Returns a copy of the data offsets array.byte[]
Returns a reference to the data array.int[]
getPixels
(int x, int y, int w, int h, int[] iArray) int
Returns pixel stride -- the number of data array elements between two samples for the same band on the same scanline.int
getSample
(int x, int y, int b) int[]
getSamples
(int x, int y, int w, int h, int b, int[] iArray) int
Returns the scanline stride -- the number of data array elements between a given sample and the sample in the same column of the next row in the same band.void
putByteData
(int x, int y, int w, int h, byte[] inData) Stores a byte array of data elements into the specified rectangular region.void
putByteData
(int x, int y, int w, int h, int band, byte[] inData) Stores a byte array of data elements into the specified rectangular region for the specified band.void
setDataElements
(int x, int y, int w, int h, Object obj) Stores an array of data elements into the specified rectangular region.void
setDataElements
(int x, int y, Raster inRaster) Stores the Raster data at the specified location.void
setDataElements
(int x, int y, Object obj) Stores the data elements for all bands at the specified location.void
setPixels
(int x, int y, int w, int h, int[] iArray) void
void
setSample
(int x, int y, int b, int s) void
setSamples
(int x, int y, int w, int h, int b, int[] iArray) toString()
Methods inherited from class java.awt.image.WritableRaster
createWritableTranslatedChild, getWritableParent, setPixel, setPixel, setPixel, setPixels, setPixels, setRect, setSample, setSample, setSamples, setSamples
Methods inherited from class java.awt.image.Raster
createBandedRaster, createBandedRaster, createBandedRaster, createCompatibleWritableRaster, createCompatibleWritableRaster, createInterleavedRaster, createInterleavedRaster, createInterleavedRaster, createPackedRaster, createPackedRaster, createPackedRaster, createPackedRaster, createRaster, createTranslatedChild, createWritableRaster, createWritableRaster, getBounds, getDataBuffer, getHeight, getMinX, getMinY, getNumBands, getNumDataElements, getParent, getPixel, getPixel, getPixel, getPixels, getPixels, getSampleDouble, getSampleFloat, getSampleModel, getSampleModelTranslateX, getSampleModelTranslateY, getSamples, getSamples, getTransferType, getWidth
-
Field Details
-
bandOffset
protected int bandOffsetprivate band offset for use by native code -
data
protected byte[] dataThe image data array. -
dataOffsets
protected int[] dataOffsetsData offsets for each band of image data. -
pixelStride
protected int pixelStridePixel stride of the image data contained in this Raster. -
scanlineStride
protected int scanlineStrideScanline stride of the image data contained in this Raster.
-
-
Constructor Details
-
SwtCompatibleRaster
-
SwtCompatibleRaster
public SwtCompatibleRaster(SampleModel paramSampleModel, DataBuffer paramDataBuffer, Rectangle aRegion, Point origin, WritableRaster paramParent) -
SwtCompatibleRaster
-
-
Method Details
-
createChild
Creates a subraster given a region of the raster. The x and y coordinates specify the horizontal and vertical offsets from the upper-left corner of this raster to the upper-left corner of the subraster. A subset of the bands of the parent Raster may be specified. If this is null, then all the bands are present in the subRaster. A translation to the subRaster may also be specified. Note that the subraster will reference the same DataBuffer as the parent raster, but using different offsets.- Overrides:
createChild
in classRaster
- Parameters:
x
- X offset.y
- Y offset.width
- Width (in pixels) of the subraster.height
- Height (in pixels) of the subraster.x0
- Translated X origin of the subraster.y0
- Translated Y origin of the subraster.bandList
- Array of band indices.- Throws:
RasterFormatException
- if the specified bounding box is outside of the parent raster.
-
createCompatibleWritableRaster
Creates a Raster with the same layout and the same width and height, and with new zeroed data arrays. If the Raster is a subRaster, this will call createCompatibleRaster(width, height).- Overrides:
createCompatibleWritableRaster
in classRaster
-
createCompatibleWritableRaster
Creates a Raster with the same layout but using a different width and height, and with new zeroed data arrays.- Overrides:
createCompatibleWritableRaster
in classRaster
-
createWritableChild
public WritableRaster createWritableChild(int x, int y, int width, int height, int x0, int y0, int[] bandList) Creates a Writable subRaster given a region of the Raster. The x and y coordinates specify the horizontal and vertical offsets from the upper-left corner of this Raster to the upper-left corner of the subRaster. A subset of the bands of the parent Raster may be specified. If this is null, then all the bands are present in the subRaster. A translation to the subRaster may also be specified. Note that the subRaster will reference the same DataBuffer as the parent Raster, but using different offsets.- Overrides:
createWritableChild
in classWritableRaster
- Parameters:
x
- X offset.y
- Y offset.width
- Width (in pixels) of the subraster.height
- Height (in pixels) of the subraster.x0
- Translated X origin of the subraster.y0
- Translated Y origin of the subraster.bandList
- Array of band indices.- Throws:
RasterFormatException
- if the specified bounding box is outside of the parent Raster.
-
getByteData
public byte[] getByteData(int x, int y, int w, int h, byte[] outData) Returns a byte array of data elements from the specified rectangular region. An ArrayIndexOutOfBounds exception will be thrown at runtime if the pixel coordinates are out of bounds.byte[] bandData = raster.getByteData(x, y, w, h, null); int numDataElements = raster.getnumDataElements(); byte[] pixel = new byte[numDataElements]; // To find a data element at location (x2, y2) System.arraycopy(bandData, ((y2 - y) * w + (x2 - x)) * numDataElements, pixel, 0, numDataElements);
- Parameters:
x
- The X coordinate of the upper left pixel location.y
- The Y coordinate of the upper left pixel location.outData
- If non-null, data elements for all bands at the specified location are returned in this array.width
- Width of the pixel rectangle.height
- Height of the pixel rectangle.- Returns:
- Data array with data elements for all bands.
-
getByteData
public byte[] getByteData(int x, int y, int w, int h, int band, byte[] outData) Returns a byte array of data elements from the specified rectangular region for the specified band. An ArrayIndexOutOfBounds exception will be thrown at runtime if the pixel coordinates are out of bounds.byte[] bandData = raster.getByteData(x, y, w, h, null); // To find the data element at location (x2, y2) byte bandElement = bandData[((y2 - y) * w + (x2 - x))];
- Parameters:
x
- The X coordinate of the upper left pixel location.y
- The Y coordinate of the upper left pixel location.band
- The band to return.outData
- If non-null, data elements for all bands at the specified location are returned in this array.width
- Width of the pixel rectangle.height
- Height of the pixel rectangle.- Returns:
- Data array with data elements for all bands.
-
getDataElements
Returns an array of data elements from the specified rectangular region. An ArrayIndexOutOfBounds exception will be thrown at runtime if the pixel coordinates are out of bounds. A ClassCastException will be thrown if the input object is non null and references anything other than an array of transferType.byte[] bandData = (byte[]) raster.getDataElements(x, y, w, h, null); int numDataElements = raster.getNumDataElements(); byte[] pixel = new byte[numDataElements]; // To find a data element at location (x2, y2) System.arraycopy(bandData, ((y2 - y) * w + (x2 - x)) * numDataElements, pixel, 0, numDataElements);
- Overrides:
getDataElements
in classRaster
- Parameters:
x
- The X coordinate of the upper left pixel location.y
- The Y coordinate of the upper left pixel location.width
- Width of the pixel rectangle.height
- Height of the pixel rectangle.outData
- An object reference to an array of type defined by getTransferType() and length w*h*getNumDataElements(). If null an array of appropriate type and size will be allocated.- Returns:
- An object reference to an array of type defined by getTransferType() with the request pixel data.
-
getDataElements
Returns the data elements for all bands at the specified location. An ArrayIndexOutOfBounds exception will be thrown at runtime if the pixel coordinate is out of bounds. A ClassCastException will be thrown if the input object is non null and references anything other than an array of transferType.- Overrides:
getDataElements
in classRaster
- Parameters:
actualX
- The X coordinate of the pixel location.actualY
- The Y coordinate of the pixel location.outData
- An object reference to an array of type defined by getTransferType() and length getNumDataElements(). If null an array of appropriate type and size will be allocated.- Returns:
- An object reference to an array of type defined by getTransferType() with the request pixel data.
-
getDataOffset
public int getDataOffset(int band) Returns the data offset for the specified band. The data offset is the index into the data array in which the first sample of the first scanline is stored.- Parameters:
band
- The band whose offset is returned.
-
getDataOffsets
public int[] getDataOffsets()Returns a copy of the data offsets array. For each band the data offset is the index into the band's data array, of the first sample of the band. -
getDataStorage
public byte[] getDataStorage()Returns a reference to the data array. -
getPixels
public int[] getPixels(int x, int y, int w, int h, int[] iArray) -
getPixelStride
public int getPixelStride()Returns pixel stride -- the number of data array elements between two samples for the same band on the same scanline. -
getSample
public int getSample(int x, int y, int b) -
getSamples
public int[] getSamples(int x, int y, int w, int h, int b, int[] iArray) - Overrides:
getSamples
in classRaster
-
getScanlineStride
public int getScanlineStride()Returns the scanline stride -- the number of data array elements between a given sample and the sample in the same column of the next row in the same band. -
putByteData
public void putByteData(int x, int y, int w, int h, byte[] inData) Stores a byte array of data elements into the specified rectangular region. An ArrayIndexOutOfBounds exception will be thrown at runtime if the pixel coordinates are out of bounds. The data elements in the data array are assumed to be packed. That is, a data element for the nth band at location (x2, y2) would be found at:inData[((y2 - y) * w + (x2 - x)) * numDataElements + n]
- Parameters:
x
- The X coordinate of the upper left pixel location.y
- The Y coordinate of the upper left pixel location.w
- Width of the pixel rectangle.h
- Height of the pixel rectangle.inData
- The data elements to be stored.
-
putByteData
public void putByteData(int x, int y, int w, int h, int band, byte[] inData) Stores a byte array of data elements into the specified rectangular region for the specified band. An ArrayIndexOutOfBounds exception will be thrown at runtime if the pixel coordinates are out of bounds. The data elements in the data array are assumed to be packed. That is, a data element at location (x2, y2) would be found at:inData[((y2 - y) * w + (x2 - x)) + n]
- Parameters:
x
- The X coordinate of the upper left pixel location.y
- The Y coordinate of the upper left pixel location.w
- Width of the pixel rectangle.h
- Height of the pixel rectangle.band
- The band to set.inData
- The data elements to be stored.
-
setDataElements
Stores an array of data elements into the specified rectangular region. An ArrayIndexOutOfBounds exception will be thrown at runtime if the pixel coordinates are out of bounds. A ClassCastException will be thrown if the input object is non null and references anything other than an array of transferType. The data elements in the data array are assumed to be packed. That is, a data element for the nth band at location (x2, y2) would be found at:inData[((y2 - y) * w + (x2 - x)) * numDataElements + n]
- Overrides:
setDataElements
in classWritableRaster
- Parameters:
x
- The X coordinate of the upper left pixel location.y
- The Y coordinate of the upper left pixel location.w
- Width of the pixel rectangle.h
- Height of the pixel rectangle.inData
- An object reference to an array of type defined by getTransferType() and length w*h*getNumDataElements() containing the pixel data to place between x,y and x+h, y+h.
-
setDataElements
Stores the data elements for all bands at the specified location. An ArrayIndexOutOfBounds exception will be thrown at runtime if the pixel coordinate is out of bounds. A ClassCastException will be thrown if the input object is non null and references anything other than an array of transferType.- Overrides:
setDataElements
in classWritableRaster
- Parameters:
x
- The X coordinate of the pixel location.y
- The Y coordinate of the pixel location.inData
- An object reference to an array of type defined by getTransferType() and length getNumDataElements() containing the pixel data to place at x,y.
-
setDataElements
Stores the Raster data at the specified location. An ArrayIndexOutOfBounds exception will be thrown at runtime if the pixel coordinates are out of bounds.- Overrides:
setDataElements
in classWritableRaster
- Parameters:
x
- The X coordinate of the pixel location.y
- The Y coordinate of the pixel location.inRaster
- Raster of data to place at x,y location.
-
setPixels
public void setPixels(int x, int y, int w, int h, int[] iArray) - Overrides:
setPixels
in classWritableRaster
-
setRect
- Overrides:
setRect
in classWritableRaster
-
setSample
public void setSample(int x, int y, int b, int s) - Overrides:
setSample
in classWritableRaster
-
setSamples
public void setSamples(int x, int y, int w, int h, int b, int[] iArray) - Overrides:
setSamples
in classWritableRaster
-
toString
-