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
-
public class SwtCompatibleRaster extends java.awt.image.WritableRaster
-
-
Field Summary
Fields Modifier and Type Field Description protected intbandOffsetprivate band offset for use by native codeprotected byte[]dataThe image data array.protected int[]dataOffsetsData offsets for each band of image data.protected intpixelStridePixel stride of the image data contained in this Raster.protected intscanlineStrideScanline stride of the image data contained in this Raster.
-
Constructor Summary
Constructors Constructor Description SwtCompatibleRaster(java.awt.image.SampleModel paramSampleModel, java.awt.image.DataBuffer paramDataBuffer, java.awt.Point origin)SwtCompatibleRaster(java.awt.image.SampleModel paramSampleModel, java.awt.image.DataBuffer paramDataBuffer, java.awt.Rectangle aRegion, java.awt.Point origin, java.awt.image.WritableRaster paramParent)SwtCompatibleRaster(java.awt.image.SampleModel paramSampleModel, java.awt.Point origin)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.image.RastercreateChild(int x, int y, int width, int height, int x0, int y0, int[] bandList)Creates a subraster given a region of the raster.java.awt.image.WritableRastercreateCompatibleWritableRaster()Creates a Raster with the same layout and the same width and height, and with new zeroed data arrays.java.awt.image.WritableRastercreateCompatibleWritableRaster(int w, int h)Creates a Raster with the same layout but using a different width and height, and with new zeroed data arrays.java.awt.image.WritableRastercreateWritableChild(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.java.lang.ObjectgetDataElements(int x, int y, int w, int h, java.lang.Object obj)Returns an array of data elements from the specified rectangular region.java.lang.ObjectgetDataElements(int actualX, int actualY, java.lang.Object obj)Returns the data elements for all bands at the specified location.intgetDataOffset(int band)Returns the data offset for the specified band.int[]getDataOffsets()Returns a copy of the data offsets array.byte[]getDataStorage()Returns a reference to the data array.int[]getPixels(int x, int y, int w, int h, int[] iArray)intgetPixelStride()Returns pixel stride -- the number of data array elements between two samples for the same band on the same scanline.intgetSample(int x, int y, int b)int[]getSamples(int x, int y, int w, int h, int b, int[] iArray)intgetScanlineStride()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.voidputByteData(int x, int y, int w, int h, byte[] inData)Stores a byte array of data elements into the specified rectangular region.voidputByteData(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.voidsetDataElements(int x, int y, int w, int h, java.lang.Object obj)Stores an array of data elements into the specified rectangular region.voidsetDataElements(int x, int y, java.awt.image.Raster inRaster)Stores the Raster data at the specified location.voidsetDataElements(int x, int y, java.lang.Object obj)Stores the data elements for all bands at the specified location.voidsetPixels(int x, int y, int w, int h, int[] iArray)voidsetRect(int dx, int dy, java.awt.image.Raster srcRaster)voidsetSample(int x, int y, int b, int s)voidsetSamples(int x, int y, int w, int h, int b, int[] iArray)java.lang.StringtoString()-
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 Detail
-
bandOffset
protected int bandOffset
private band offset for use by native code
-
data
protected byte[] data
The image data array.
-
dataOffsets
protected int[] dataOffsets
Data offsets for each band of image data.
-
pixelStride
protected int pixelStride
Pixel stride of the image data contained in this Raster.
-
scanlineStride
protected int scanlineStride
Scanline stride of the image data contained in this Raster.
-
-
Constructor Detail
-
SwtCompatibleRaster
public SwtCompatibleRaster(java.awt.image.SampleModel paramSampleModel, java.awt.image.DataBuffer paramDataBuffer, java.awt.Point origin)
-
SwtCompatibleRaster
public SwtCompatibleRaster(java.awt.image.SampleModel paramSampleModel, java.awt.image.DataBuffer paramDataBuffer, java.awt.Rectangle aRegion, java.awt.Point origin, java.awt.image.WritableRaster paramParent)
-
SwtCompatibleRaster
public SwtCompatibleRaster(java.awt.image.SampleModel paramSampleModel, java.awt.Point origin)
-
-
Method Detail
-
createChild
public java.awt.image.Raster createChild(int x, int y, int width, int height, int x0, int y0, int[] bandList)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:
createChildin classjava.awt.image.Raster- 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:
java.awt.image.RasterFormatException- if the specified bounding box is outside of the parent raster.
-
createCompatibleWritableRaster
public java.awt.image.WritableRaster 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:
createCompatibleWritableRasterin classjava.awt.image.Raster
-
createCompatibleWritableRaster
public java.awt.image.WritableRaster 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.- Overrides:
createCompatibleWritableRasterin classjava.awt.image.Raster
-
createWritableChild
public java.awt.image.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:
createWritableChildin classjava.awt.image.WritableRaster- 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:
java.awt.image.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.width- Width of the pixel rectangle.height- Height of the pixel rectangle.outData- If non-null, data elements for all bands at the specified location are returned in this array.- 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.width- Width of the pixel rectangle.height- Height of the pixel rectangle.band- The band to return.outData- If non-null, data elements for all bands at the specified location are returned in this array.- Returns:
- Data array with data elements for all bands.
-
getDataElements
public java.lang.Object getDataElements(int x, int y, int w, int h, java.lang.Object obj)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:
getDataElementsin classjava.awt.image.Raster- 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
public java.lang.Object getDataElements(int actualX, int actualY, java.lang.Object obj)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:
getDataElementsin classjava.awt.image.Raster- 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)- Overrides:
getPixelsin classjava.awt.image.Raster
-
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)- Overrides:
getSamplein classjava.awt.image.Raster
-
getSamples
public int[] getSamples(int x, int y, int w, int h, int b, int[] iArray)- Overrides:
getSamplesin classjava.awt.image.Raster
-
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
public void setDataElements(int x, int y, int w, int h, java.lang.Object obj)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:
setDataElementsin classjava.awt.image.WritableRaster- 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
public void setDataElements(int x, int y, java.lang.Object obj)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:
setDataElementsin classjava.awt.image.WritableRaster- 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
public void setDataElements(int x, int y, java.awt.image.Raster inRaster)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:
setDataElementsin classjava.awt.image.WritableRaster- 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:
setPixelsin classjava.awt.image.WritableRaster
-
setRect
public void setRect(int dx, int dy, java.awt.image.Raster srcRaster)- Overrides:
setRectin classjava.awt.image.WritableRaster
-
setSample
public void setSample(int x, int y, int b, int s)- Overrides:
setSamplein classjava.awt.image.WritableRaster
-
setSamples
public void setSamples(int x, int y, int w, int h, int b, int[] iArray)- Overrides:
setSamplesin classjava.awt.image.WritableRaster
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-