| sun.awt.image.SunWritableRaster sun.awt.image.BytePackedRaster
BytePackedRaster | public class BytePackedRaster extends SunWritableRaster (Code) | | This class is useful for describing 1, 2, or 4 bit image data
elements. This raster has one band whose pixels are packed
together into individual bytes in a single byte array. This type
of raster can be used with an IndexColorModel. This raster uses a
MultiPixelPackedSampleModel.
version: 10 Feb 1997 |
Field Summary | |
int | bitMask The bit mask for extracting the pixel. | byte[] | data The image data array. | int | dataBitOffset The data bit offset for each pixel. | int | pixelBitStride The bit stride of a pixel, equal to the total number of bits
required to store a pixel. | int | scanlineStride Scanline stride of the image data contained in this Raster. | int | shiftOffset 8 minus the pixel bit stride. | int | type |
Constructor Summary | |
public | BytePackedRaster(SampleModel sampleModel, Point origin) Constructs a BytePackedRaster with the given SampleModel.
The Raster's upper left corner is origin and it is the same
size as the SampleModel. | public | BytePackedRaster(SampleModel sampleModel, DataBuffer dataBuffer, Point origin) Constructs a BytePackedRaster with the given SampleModel
and DataBuffer. | public | BytePackedRaster(SampleModel sampleModel, DataBuffer dataBuffer, Rectangle aRegion, Point origin, BytePackedRaster parent) Constructs a BytePackedRaster with the given SampleModel,
DataBuffer, and parent. |
Method Summary | |
public 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. | public 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. | public WritableRaster | createCompatibleWritableRaster() Creates a raster with the same layout and the same
width and height, and with new zeroed data arrays. | 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. | public byte[] | getByteData(int x, int y, int w, int h, int band, byte[] outData) Returns a byte array containing the specified data elements
from the data array. | public byte[] | getByteData(int x, int y, int w, int h, byte[] outData) Returns a byte array containing the specified data elements
from the data array.
An ArrayIndexOutOfBounds exception will be thrown at runtime
if the pixel coordinates are out of bounds.
byte[] byteData = raster.getByteData(x, y, w, h, null);
byte pixel;
// To find a data element at location (x2, y2)
pixel = byteData[((y2-y)*w + (x2-x))];
Parameters: x - The X coordinate of the upper left pixel location. Parameters: y - The Y coordinate of the upper left pixel location. Parameters: width - Width of the pixel rectangle. Parameters: height - Height of the pixel rectangle. Parameters: outData - If non-null, data elementsat the specified locations are returned in this array. | public int | getDataBitOffset() Returns the data bit offset for the Raster. | public Object | getDataElements(int x, int y, Object obj) Returns the data element at the specified
location. | public Object | getDataElements(int x, int y, int w, int h, Object outData) Returns the pixel data for the specified rectangle of pixels in a
primitive array of type TransferType.
For image data supported by the Java 2D API, this
will be one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, or
DataBuffer.TYPE_INT. | public byte[] | getDataStorage() Returns a reference to the entire data array. | public int | getPixelBitStride() Returns pixel bit stride -- the number of bits between two
samples on the same scanline. | public Object | getPixelData(int x, int y, int w, int h, 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.getPixelData(x, y, w, h, null);
int pixel;
// To find a data element at location (x2, y2)
pixel = bandData[((y2-y)*w + (x2-x))];
Parameters: x - The X coordinate of the upper left pixel location. Parameters: y - The Y coordinate of the upper left pixel location. Parameters: width - Width of the pixel rectangle. Parameters: height - Height of the pixel rectangle. Parameters: outData - An object reference to an array of type defined bygetTransferType() and length w*h*getNumDataElements().If null an array of appropriate type and size will beallocated. | public int[] | getPixels(int x, int y, int w, int h, int iArray) Returns an int array containing all samples for a rectangle of pixels,
one sample per array element. | 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. | 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. | 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. | public void | setDataElements(int x, int y, Object obj) Stores the data elements at the specified location. | public void | setDataElements(int x, int y, Raster inRaster) Stores the Raster data at the specified location. | public void | setDataElements(int x, int y, int w, int h, 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. | public void | setPixels(int x, int y, int w, int h, int iArray) Sets all samples for a rectangle of pixels from an int array containing
one sample per array element. | public void | setRect(int dx, int dy, Raster srcRaster) Copies pixels from Raster srcRaster to this WritableRaster.
For each (x, y) address in srcRaster, the corresponding pixel
is copied to address (x+dx, y+dy) in this WritableRaster,
unless (x+dx, y+dy) falls outside the bounds of this raster.
srcRaster must have the same number of bands as this WritableRaster.
The copy is a simple copy of source samples to the corresponding
destination samples. | public String | toString() |
bitMask | int bitMask(Code) | | The bit mask for extracting the pixel.
|
data | byte[] data(Code) | | The image data array.
|
dataBitOffset | int dataBitOffset(Code) | | The data bit offset for each pixel.
|
pixelBitStride | int pixelBitStride(Code) | | The bit stride of a pixel, equal to the total number of bits
required to store a pixel.
|
scanlineStride | int scanlineStride(Code) | | Scanline stride of the image data contained in this Raster.
|
shiftOffset | int shiftOffset(Code) | | 8 minus the pixel bit stride.
|
BytePackedRaster | public BytePackedRaster(SampleModel sampleModel, Point origin)(Code) | | Constructs a BytePackedRaster with the given SampleModel.
The Raster's upper left corner is origin and it is the same
size as the SampleModel. A DataBuffer large enough to describe the
Raster is automatically created. SampleModel must be of type
MultiPixelPackedSampleModel.
Parameters: sampleModel - The SampleModel that specifies the layout. Parameters: origin - The Point that specified the origin. |
BytePackedRaster | public BytePackedRaster(SampleModel sampleModel, DataBuffer dataBuffer, Point origin)(Code) | | Constructs a BytePackedRaster with the given SampleModel
and DataBuffer. The Raster's upper left corner is origin and
it is the same size as the SampleModel. The DataBuffer is not
initialized and must be a DataBufferByte compatible with SampleModel.
SampleModel must be of type MultiPixelPackedSampleModel.
Parameters: sampleModel - The SampleModel that specifies the layout. Parameters: dataBuffer - The DataBufferShort that contains the image data. Parameters: origin - The Point that specifies the origin. |
BytePackedRaster | public BytePackedRaster(SampleModel sampleModel, DataBuffer dataBuffer, Rectangle aRegion, Point origin, BytePackedRaster parent)(Code) | | Constructs a BytePackedRaster with the given SampleModel,
DataBuffer, and parent. DataBuffer must be a DataBufferByte and
SampleModel must be of type MultiPixelPackedSampleModel.
When translated into the base Raster's
coordinate system, aRegion must be contained by the base Raster.
Origin is the coordinate in the new Raster's coordinate system of
the origin of the base Raster. (The base Raster is the Raster's
ancestor which has no parent.)
Note that this constructor should generally be called by other
constructors or create methods, it should not be used directly.
Parameters: sampleModel - The SampleModel that specifies the layout. Parameters: dataBuffer - The DataBufferShort that contains the image data. Parameters: aRegion - The Rectangle that specifies the image area. Parameters: origin - The Point that specifies the origin. Parameters: parent - The parent (if any) of this raster. exception: RasterFormatException - if the parameters do not conformto requirements of this Raster type. |
createChild | public Raster createChild(int x, int y, int width, int height, int x0, int y0, int[] bandList)(Code) | | 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. Note that the subraster will reference the same
DataBuffer as the parent raster, but using different offsets. The
bandList is ignored.
Parameters: x - X offset. Parameters: y - Y offset. Parameters: width - Width (in pixels) of the subraster. Parameters: height - Height (in pixels) of the subraster. Parameters: x0 - Translated X origin of the subraster. Parameters: y0 - Translated Y origin of the subraster. Parameters: bandList - Array of band indices. exception: RasterFormatException - if the specified bounding box is outside of the parent raster. |
createCompatibleWritableRaster | public WritableRaster createCompatibleWritableRaster(int w, int h)(Code) | | Creates a raster with the same layout but using a different
width and height, and with new zeroed data arrays.
|
createCompatibleWritableRaster | public WritableRaster createCompatibleWritableRaster()(Code) | | Creates a raster with the same layout and the same
width and height, and with new zeroed data arrays.
|
createWritableChild | public WritableRaster createWritableChild(int x, int y, int width, int height, int x0, int y0, int[] bandList)(Code) | | 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. The bandList is ignored.
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.
Parameters: x - X offset. Parameters: y - Y offset. Parameters: width - Width (in pixels) of the subraster. Parameters: height - Height (in pixels) of the subraster. Parameters: x0 - Translated X origin of the subraster. Parameters: y0 - Translated Y origin of the subraster. Parameters: bandList - Array of band indices. exception: RasterFormatException - if the specified bounding box is outside of the parent Raster. |
getByteData | public byte[] getByteData(int x, int y, int w, int h, int band, byte[] outData)(Code) | | Returns a byte array containing the specified data elements
from the data array. The band index will be ignored.
An ArrayIndexOutOfBounds exception will be thrown at runtime
if the pixel coordinates are out of bounds.
byte[] byteData = getByteData(x, y, band, w, h, null);
// To find a data element at location (x2, y2)
byte element = byteData[(y2-y)*w + (x2-x)];
Parameters: x - The X coordinate of the upper left pixel location. Parameters: y - The Y coordinate of the upper left pixel location. Parameters: width - Width of the pixel rectangle. Parameters: height - Height of the pixel rectangle. Parameters: band - The band to return, is ignored. Parameters: outData - If non-null, data elementsat the specified locations are returned in this array. Byte array with data elements. |
getByteData | public byte[] getByteData(int x, int y, int w, int h, byte[] outData)(Code) | | Returns a byte array containing the specified data elements
from the data array.
An ArrayIndexOutOfBounds exception will be thrown at runtime
if the pixel coordinates are out of bounds.
byte[] byteData = raster.getByteData(x, y, w, h, null);
byte pixel;
// To find a data element at location (x2, y2)
pixel = byteData[((y2-y)*w + (x2-x))];
Parameters: x - The X coordinate of the upper left pixel location. Parameters: y - The Y coordinate of the upper left pixel location. Parameters: width - Width of the pixel rectangle. Parameters: height - Height of the pixel rectangle. Parameters: outData - If non-null, data elementsat the specified locations are returned in this array. Byte array with data elements. |
getDataBitOffset | public int getDataBitOffset()(Code) | | Returns the data bit offset for the Raster. The data
bit offset is the bit index into the data array element
corresponding to the first sample of the first scanline.
|
getDataElements | public Object getDataElements(int x, int y, Object obj)(Code) | | Returns the data element 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.
Parameters: x - The X coordinate of the pixel location. Parameters: y - The Y coordinate of the pixel location. Parameters: outData - An object reference to an array of type defined bygetTransferType() and length getNumDataElements().If null an array of appropriate type and size will beallocated. An object reference to an array of type defined bygetTransferType() with the request pixel data. |
getDataElements | public Object getDataElements(int x, int y, int w, int h, Object outData)(Code) | | Returns the pixel data for the specified rectangle of pixels in a
primitive array of type TransferType.
For image data supported by the Java 2D API, this
will be one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, or
DataBuffer.TYPE_INT. Data may be returned in a packed format,
thus increasing efficiency for data transfers.
An ArrayIndexOutOfBoundsException may be thrown
if the coordinates are not in bounds.
A ClassCastException will be thrown if the input object is non null
and references anything other than an array of TransferType.
See Also: java.awt.image.SampleModel.getDataElements(intintintintObjectDataBuffer) Parameters: x - The X coordinate of the upper left pixel location. Parameters: y - The Y coordinate of the upper left pixel location. Parameters: w - Width of the pixel rectangle. Parameters: h - Height of the pixel rectangle. Parameters: outData - An object reference to an array of type defined bygetTransferType() and length w*h*getNumDataElements(). If null, an array of appropriate type and size will beallocated. An object reference to an array of type defined bygetTransferType() with the requested pixel data. |
getDataStorage | public byte[] getDataStorage()(Code) | | Returns a reference to the entire data array.
|
getPixelBitStride | public int getPixelBitStride()(Code) | | Returns pixel bit stride -- the number of bits between two
samples on the same scanline.
|
getPixelData | public Object getPixelData(int x, int y, int w, int h, Object obj)(Code) | | 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.getPixelData(x, y, w, h, null);
int pixel;
// To find a data element at location (x2, y2)
pixel = bandData[((y2-y)*w + (x2-x))];
Parameters: x - The X coordinate of the upper left pixel location. Parameters: y - The Y coordinate of the upper left pixel location. Parameters: width - Width of the pixel rectangle. Parameters: height - Height of the pixel rectangle. Parameters: outData - An object reference to an array of type defined bygetTransferType() and length w*h*getNumDataElements().If null an array of appropriate type and size will beallocated. An object reference to an array of type defined bygetTransferType() with the request pixel data. |
getPixels | public int[] getPixels(int x, int y, int w, int h, int iArray)(Code) | | Returns an int array containing all samples for a rectangle of pixels,
one sample per array element.
An ArrayIndexOutOfBoundsException may be thrown
if the coordinates are not in bounds.
x, y the coordinates of the upper-left pixel location Parameters: w - Width of the pixel rectangle Parameters: h - Height of the pixel rectangle Parameters: iArray - An optionally pre-allocated int array the samples for the specified rectangle of pixels. |
getScanlineStride | public int getScanlineStride()(Code) | | 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.
|
putByteData | public void putByteData(int x, int y, int w, int h, int band, byte[] inData)(Code) | | Stores a byte array of data elements into the specified rectangular
region. The band index will be ignored.
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))]
Parameters: x - The X coordinate of the upper left pixel location. Parameters: y - The Y coordinate of the upper left pixel location. Parameters: w - Width of the pixel rectangle. Parameters: h - Height of the pixel rectangle. Parameters: band - The band to set, is ignored. Parameters: inData - The data elements to be stored. |
putByteData | public void putByteData(int x, int y, int w, int h, byte[] inData)(Code) | | 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
at location (x2, y2) would be found at:
inData[((y2-y)*w + (x2-x))]
Parameters: x - The X coordinate of the upper left pixel location. Parameters: y - The Y coordinate of the upper left pixel location. Parameters: w - Width of the pixel rectangle. Parameters: h - Height of the pixel rectangle. Parameters: inData - The data elements to be stored. |
setDataElements | public void setDataElements(int x, int y, Object obj)(Code) | | Stores the data elements 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.
Parameters: x - The X coordinate of the pixel location. Parameters: y - The Y coordinate of the pixel location. Parameters: inData - An object reference to an array of type defined bygetTransferType() and length getNumDataElements()containing the pixel data to place at x,y. |
setDataElements | public void setDataElements(int x, int y, Raster inRaster)(Code) | | Stores the Raster data at the specified location.
An ArrayIndexOutOfBounds exception will be thrown at runtime
if the pixel coordinates are out of bounds.
Parameters: x - The X coordinate of the pixel location. Parameters: y - The Y coordinate of the pixel location. Parameters: inRaster - Raster of data to place at x,y location. |
setDataElements | public void setDataElements(int x, int y, int w, int h, Object obj)(Code) | | 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
at location (x2, y2) would be found at:
inData[((y2-y)*w + (x2-x))]
Parameters: x - The X coordinate of the upper left pixel location. Parameters: y - The Y coordinate of the upper left pixel location. Parameters: w - Width of the pixel rectangle. Parameters: h - Height of the pixel rectangle. Parameters: inData - An object reference to an array of type defined bygetTransferType() and length w*h*getNumDataElements()containing the pixel data to place between x,y andx+h, y+h. |
setPixels | public void setPixels(int x, int y, int w, int h, int iArray)(Code) | | Sets all samples for a rectangle of pixels from an int array containing
one sample per array element.
An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
Parameters: x - The X coordinate of the upper left pixel location. Parameters: y - The Y coordinate of the upper left pixel location. Parameters: w - Width of the pixel rectangle. Parameters: h - Height of the pixel rectangle. Parameters: iArray - The input int pixel array. |
setRect | public void setRect(int dx, int dy, Raster srcRaster)(Code) | | Copies pixels from Raster srcRaster to this WritableRaster.
For each (x, y) address in srcRaster, the corresponding pixel
is copied to address (x+dx, y+dy) in this WritableRaster,
unless (x+dx, y+dy) falls outside the bounds of this raster.
srcRaster must have the same number of bands as this WritableRaster.
The copy is a simple copy of source samples to the corresponding
destination samples. For details, see
WritableRaster.setRect(Raster) .
Parameters: dx - The X translation factor from src space to dst spaceof the copy. Parameters: dy - The Y translation factor from src space to dst spaceof the copy. Parameters: srcRaster - The Raster from which to copy pixels. |
|
|