java.lang.Object | ||||
↳ | java.awt.image.Raster | |||
↳ | java.awt.image.WritableRaster | |||
↳ | sun.awt.image.SunWritableRaster | |||
↳ | sun.awt.image.BytePackedRaster |
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.
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a BytePackedRaster with the given SampleModel.
| |||||||||||
Constructs a BytePackedRaster with the given SampleModel
and DataBuffer.
| |||||||||||
Constructs a BytePackedRaster with the given SampleModel,
DataBuffer, and parent.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
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.
| |||||||||||
Creates a raster with the same layout but using a different
width and height, and with new zeroed data arrays.
| |||||||||||
Creates a Writable subRaster given a region of the Raster.
| |||||||||||
Returns a byte array containing the specified data elements
from the data array.
| |||||||||||
Returns a byte array containing the specified data elements
from the data array.
| |||||||||||
Returns the data bit offset for the Raster.
| |||||||||||
Returns the pixel data for the specified rectangle of pixels in a
primitive array of type TransferType.
| |||||||||||
Returns the data element at the specified
location.
| |||||||||||
Returns a reference to the entire data array.
| |||||||||||
Returns pixel bit stride -- the number of bits between two
samples on the same scanline.
| |||||||||||
Returns an array of data elements from the specified rectangular
region.
| |||||||||||
Returns an int array containing all samples for a rectangle of pixels,
one sample per array element.
| |||||||||||
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.
| |||||||||||
Stores a byte array of data elements into the specified rectangular
region.
| |||||||||||
Stores a byte array of data elements into the specified rectangular
region.
| |||||||||||
Stores an array of data elements into the specified rectangular
region.
| |||||||||||
Stores the Raster data at the specified location.
| |||||||||||
Stores the data elements at the specified location.
| |||||||||||
Sets all samples for a rectangle of pixels from an int array containing
one sample per array element.
| |||||||||||
Copies pixels from Raster srcRaster to this WritableRaster.
| |||||||||||
Returns a string representation of the object.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() |
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.
sampleModel | The SampleModel that specifies the layout. |
---|---|
origin | The Point that specified the origin. |
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.
sampleModel | The SampleModel that specifies the layout. |
---|---|
dataBuffer | The DataBufferShort that contains the image data. |
origin | The Point that specifies the origin. |
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.
sampleModel | The SampleModel that specifies the layout. |
---|---|
dataBuffer | The DataBufferShort that contains the image data. |
aRegion | The Rectangle that specifies the image area. |
origin | The Point that specifies the origin. |
parent | The parent (if any) of this raster. |
RasterFormatException | if the parameters do not conform to requirements of this Raster type. |
---|
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.
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. |
Raster
.RasterFormatException | if the specified bounding box is outside of the parent raster. |
---|
Creates a raster with the same layout and the same width and height, and with new zeroed data arrays.
WritableRaster
with the same sample
model and a new data buffer.
Creates a raster with the same layout but using a different width and height, and with new zeroed data arrays.
w | the specified width of the new WritableRaster |
---|---|
h | the specified height of the new WritableRaster |
WritableRaster
with the specified
size and a new sample model and data buffer.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.
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. |
WritableRaster
sharing all or part of the
DataBuffer
of this WritableRaster
.RasterFormatException | if the specified bounding box is outside of the parent Raster. |
---|
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)];
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, is ignored. |
outData | If non-null, data elements at the specified locations are returned in this array. |
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))];
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 at the specified locations are returned in this array. |
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.
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.
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. |
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 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.
x | The X coordinate of the pixel location. |
---|---|
y | The Y coordinate of the pixel location. |
obj | 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 a reference to the entire data array.
Returns pixel bit stride -- the number of bits between two samples on the same scanline.
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))];
x | The X coordinate of the upper left pixel location. |
---|---|
y | The Y coordinate of the upper left pixel location. |
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 | 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 |
iArray | An optionally pre-allocated int array |
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.
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))]
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. |
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))]
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, is ignored. |
inData | The data elements to be stored. |
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))]
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. |
obj | 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+w-1, y+h-1. |
Stores the Raster data at the specified location. An ArrayIndexOutOfBounds exception will be thrown at runtime if the pixel coordinates are out of bounds.
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. |
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.
x | The X coordinate of the pixel location. |
---|---|
y | The Y coordinate of the pixel location. |
obj | An object reference to an array of type defined by getTransferType() and length getNumDataElements() containing the pixel data to place at x,y. |
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.
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. |
iArray | The input int pixel array. |
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
setRect(Raster)
.
dx | The X translation factor from src space to dst space of the copy. |
---|---|
dy | The Y translation factor from src space to dst space of the copy. |
srcRaster | The Raster from which to copy pixels. |
Returns a string representation of the object. In general, the
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())