Rasterpublic class Raster extends Object The Raster class represents a rectangular area of pixels. This class is
defined by DataBuffer and SampleModel objects. The DataBuffer object stores
sample values and DSampleModel defines the location of sample in this
DataBuffer. |
Fields Summary |
---|
protected DataBuffer | dataBufferThe DataBuffer of this Raster. | protected int | heightThe height of this Raster. | protected int | minXThe X coordinate of the upper left pixel in this Raster. | protected int | minYThe Y coordinate of the upper left pixel in this Raster. | protected int | numBandsThe number of bands in this Raster. | protected int | numDataElementsThe number of data elements. | protected Raster | parentThe parent of this Raster. | protected SampleModel | sampleModelThe SampleModel of this Raster. | protected int | sampleModelTranslateXThe X translation from the coordinate space of the SampleModel of this
Raster. | protected int | sampleModelTranslateYThe Y translation from the coordinate space of the SampleModel of this
Raster. | protected int | widthThe width of this Raster. |
Constructors Summary |
---|
protected Raster(SampleModel sampleModel, DataBuffer dataBuffer, Point origin)Instantiates a new Raster object with the specified SampleModel and
DataBuffer.
this(sampleModel, dataBuffer, new Rectangle(origin.x, origin.y, sampleModel.getWidth(),
sampleModel.getHeight()), origin, null);
| protected Raster(SampleModel sampleModel, DataBuffer dataBuffer, Rectangle aRegion, Point sampleModelTranslate, Raster parent)Instantiates a new Raster object with the specified SampleModel,
DataBuffer, rectangular region and parent Raster.
if (sampleModel == null || dataBuffer == null || aRegion == null
|| sampleModelTranslate == null) {
// awt.281=sampleModel, dataBuffer, aRegion or sampleModelTranslate
// is null
throw new NullPointerException(Messages.getString("awt.281")); //$NON-NLS-1$
}
if (aRegion.width <= 0 || aRegion.height <= 0) {
// awt.282=aRegion has width or height less than or equal to zero
throw new RasterFormatException(Messages.getString("awt.282")); //$NON-NLS-1$
}
if ((long)aRegion.x + (long)aRegion.width > Integer.MAX_VALUE) {
// awt.283=Overflow X coordinate of Raster
throw new RasterFormatException(Messages.getString("awt.283")); //$NON-NLS-1$
}
if ((long)aRegion.y + (long)aRegion.height > Integer.MAX_VALUE) {
// awt.284=Overflow Y coordinate of Raster
throw new RasterFormatException(Messages.getString("awt.284")); //$NON-NLS-1$
}
if (sampleModel instanceof ComponentSampleModel) {
validateDataBuffer(dataBuffer, aRegion.width, aRegion.height,
((ComponentSampleModel)sampleModel).getScanlineStride());
} else if (sampleModel instanceof MultiPixelPackedSampleModel) {
validateDataBuffer(dataBuffer, aRegion.width, aRegion.height,
((MultiPixelPackedSampleModel)sampleModel).getScanlineStride());
} else if (sampleModel instanceof SinglePixelPackedSampleModel) {
validateDataBuffer(dataBuffer, aRegion.width, aRegion.height,
((SinglePixelPackedSampleModel)sampleModel).getScanlineStride());
}
this.sampleModel = sampleModel;
this.dataBuffer = dataBuffer;
this.minX = aRegion.x;
this.minY = aRegion.y;
this.width = aRegion.width;
this.height = aRegion.height;
this.sampleModelTranslateX = sampleModelTranslate.x;
this.sampleModelTranslateY = sampleModelTranslate.y;
this.parent = parent;
this.numBands = sampleModel.getNumBands();
this.numDataElements = sampleModel.getNumDataElements();
| protected Raster(SampleModel sampleModel, Point origin)Instantiates a new Raster with the specified SampleModel.
this(sampleModel, sampleModel.createDataBuffer(), new Rectangle(origin.x, origin.y,
sampleModel.getWidth(), sampleModel.getHeight()), origin, null);
|
Methods Summary |
---|
public static java.awt.image.WritableRaster | createBandedRaster(java.awt.image.DataBuffer dataBuffer, int w, int h, int scanlineStride, int[] bankIndices, int[] bandOffsets, java.awt.Point location)Creates a Raster object with a BandedSampleModel and the specified
DataBuffer. The number of bands is defined by the length of bandOffsets
or bankIndices arrays.
if (w <= 0 || h <= 0) {
// awt.22E=w or h is less than or equal to zero
throw new RasterFormatException(Messages.getString("awt.22E")); //$NON-NLS-1$
}
if (location == null) {
location = new Point(0, 0);
}
if ((long)location.x + w > Integer.MAX_VALUE || (long)location.y + h > Integer.MAX_VALUE) {
// awt.276=location.x + w or location.y + h results in integer
// overflow
throw new RasterFormatException(Messages.getString("awt.276")); //$NON-NLS-1$
}
if (bankIndices == null || bandOffsets == null) {
// awt.277=bankIndices or bandOffsets is null
throw new ArrayIndexOutOfBoundsException(Messages.getString("awt.277")); //$NON-NLS-1$
}
if (dataBuffer == null) {
// awt.278=dataBuffer is null
throw new NullPointerException(Messages.getString("awt.278")); //$NON-NLS-1$
}
int dataType = dataBuffer.getDataType();
if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_USHORT
&& dataType != DataBuffer.TYPE_INT) {
// awt.230=dataType is not one of the supported data types
throw new IllegalArgumentException(Messages.getString("awt.230")); //$NON-NLS-1$
}
BandedSampleModel sampleModel = new BandedSampleModel(dataType, w, h, scanlineStride,
bankIndices, bandOffsets);
return new OrdinaryWritableRaster(sampleModel, dataBuffer, location);
| public static java.awt.image.WritableRaster | createBandedRaster(int dataType, int w, int h, int scanlineStride, int[] bankIndices, int[] bandOffsets, java.awt.Point location)Creates a Raster object with a BandedSampleModel and the specified data
type. The Data type can be one of the following values: TYPE_BYTE,
TYPE_USHORT, or TYPE_INT.
if (w <= 0 || h <= 0) {
// awt.22E=w or h is less than or equal to zero
throw new RasterFormatException(Messages.getString("awt.22E")); //$NON-NLS-1$
}
if (location == null) {
location = new Point(0, 0);
}
if ((long)location.x + w > Integer.MAX_VALUE || (long)location.y + h > Integer.MAX_VALUE) {
// awt.276=location.x + w or location.y + h results in integer
// overflow
throw new RasterFormatException(Messages.getString("awt.276")); //$NON-NLS-1$
}
if (bankIndices == null || bandOffsets == null) {
// awt.277=bankIndices or bandOffsets is null
throw new ArrayIndexOutOfBoundsException(Messages.getString("awt.277")); //$NON-NLS-1$
}
if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_USHORT
&& dataType != DataBuffer.TYPE_INT) {
// awt.230=dataType is not one of the supported data types
throw new IllegalArgumentException(Messages.getString("awt.230")); //$NON-NLS-1$
}
int maxOffset = bandOffsets[0];
int maxBank = bankIndices[0];
for (int i = 0; i < bankIndices.length; i++) {
if (bandOffsets[i] > maxOffset) {
maxOffset = bandOffsets[i];
}
if (bankIndices[i] > maxBank) {
maxBank = bankIndices[i];
}
}
int numBanks = maxBank + 1;
int dataSize = scanlineStride * (h - 1) + w + maxOffset;
DataBuffer data = null;
switch (dataType) {
case DataBuffer.TYPE_BYTE:
data = new DataBufferByte(dataSize, numBanks);
break;
case DataBuffer.TYPE_USHORT:
data = new DataBufferUShort(dataSize, numBanks);
break;
case DataBuffer.TYPE_INT:
data = new DataBufferInt(dataSize, numBanks);
break;
}
return createBandedRaster(data, w, h, scanlineStride, bankIndices, bandOffsets, location);
| public static java.awt.image.WritableRaster | createBandedRaster(int dataType, int w, int h, int bands, java.awt.Point location)Creates a Raster object with a BandedSampleModel and the specified data
type. The Data type can be one of the following values: TYPE_BYTE,
TYPE_USHORT, or TYPE_INT.
if (w <= 0 || h <= 0) {
// awt.22E=w or h is less than or equal to zero
throw new RasterFormatException(Messages.getString("awt.22E")); //$NON-NLS-1$
}
if (location == null) {
location = new Point(0, 0);
}
if ((long)location.x + w > Integer.MAX_VALUE || (long)location.y + h > Integer.MAX_VALUE) {
// awt.276=location.x + w or location.y + h results in integer
// overflow
throw new RasterFormatException(Messages.getString("awt.276")); //$NON-NLS-1$
}
if (bands < 1) {
// awt.279=bands is less than 1
throw new ArrayIndexOutOfBoundsException(Messages.getString("awt.279")); //$NON-NLS-1$
}
int bandOffsets[] = new int[bands];
int bankIndices[] = new int[bands];
for (int i = 0; i < bands; i++) {
bandOffsets[i] = 0;
bankIndices[i] = i;
}
return createBandedRaster(dataType, w, h, w, bankIndices, bandOffsets, location);
| public java.awt.image.Raster | createChild(int parentX, int parentY, int width, int height, int childMinX, int childMinY, int[] bandList)Creates the child of this Raster by sharing the specified rectangular
area in this raster. The parentX, parentY, width and height parameters
specify the rectangular area to be shared.
if (width <= 0 || height <= 0) {
// awt.285=Width or Height of child Raster is less than or equal to
// zero
throw new RasterFormatException(Messages.getString("awt.285")); //$NON-NLS-1$
}
if (parentX < this.minX || parentX + width > this.minX + this.width) {
// awt.286=parentX disposes outside Raster
throw new RasterFormatException(Messages.getString("awt.286")); //$NON-NLS-1$
}
if (parentY < this.minY || parentY + height > this.minY + this.height) {
// awt.287=parentY disposes outside Raster
throw new RasterFormatException(Messages.getString("awt.287")); //$NON-NLS-1$
}
if ((long)parentX + width > Integer.MAX_VALUE) {
// awt.288=parentX + width results in integer overflow
throw new RasterFormatException(Messages.getString("awt.288")); //$NON-NLS-1$
}
if ((long)parentY + height > Integer.MAX_VALUE) {
// awt.289=parentY + height results in integer overflow
throw new RasterFormatException(Messages.getString("awt.289")); //$NON-NLS-1$
}
if ((long)childMinX + width > Integer.MAX_VALUE) {
// awt.28A=childMinX + width results in integer overflow
throw new RasterFormatException(Messages.getString("awt.28A")); //$NON-NLS-1$
}
if ((long)childMinY + height > Integer.MAX_VALUE) {
// awt.28B=childMinY + height results in integer overflow
throw new RasterFormatException(Messages.getString("awt.28B")); //$NON-NLS-1$
}
SampleModel childModel;
if (bandList == null) {
childModel = sampleModel;
} else {
childModel = sampleModel.createSubsetSampleModel(bandList);
}
int childTranslateX = childMinX - parentX;
int childTranslateY = childMinY - parentY;
return new Raster(childModel, dataBuffer,
new Rectangle(childMinX, childMinY, width, height), new Point(childTranslateX
+ sampleModelTranslateX, childTranslateY + sampleModelTranslateY), this);
| public java.awt.image.WritableRaster | createCompatibleWritableRaster()Create a compatible WritableRaster with the same parameters as this
Raster.
return new OrdinaryWritableRaster(sampleModel, new Point(0, 0));
| public java.awt.image.WritableRaster | createCompatibleWritableRaster(int w, int h)Create a compatible WritableRaster with the same parameters as this
Raster and the specified size.
if (w <= 0 || h <= 0) {
// awt.22E=w or h is less than or equal to zero
throw new RasterFormatException(Messages.getString("awt.22E")); //$NON-NLS-1$
}
SampleModel sm = sampleModel.createCompatibleSampleModel(w, h);
return new OrdinaryWritableRaster(sm, new Point(0, 0));
| public java.awt.image.WritableRaster | createCompatibleWritableRaster(int x, int y, int w, int h)Create a compatible WritableRaster with the same parameters as this
Raster and the specified size and location.
WritableRaster raster = createCompatibleWritableRaster(w, h);
return raster.createWritableChild(0, 0, w, h, x, y, null);
| public java.awt.image.WritableRaster | createCompatibleWritableRaster(java.awt.Rectangle rect)Create a compatible WritableRaster with the same parameters as this
Raster and the specified rectangle which determines new WritableRaster's
location and size.
if (rect == null) {
// awt.28C=Rect is null
throw new NullPointerException(Messages.getString("awt.28C")); //$NON-NLS-1$
}
return createCompatibleWritableRaster(rect.x, rect.y, rect.width, rect.height);
| public static java.awt.image.WritableRaster | createInterleavedRaster(java.awt.image.DataBuffer dataBuffer, int w, int h, int scanlineStride, int pixelStride, int[] bandOffsets, java.awt.Point location)Creates a Raster object with a PixelInterleavedSampleModel and the
specified DataBuffer.
if (w <= 0 || h <= 0) {
// awt.22E=w or h is less than or equal to zero
throw new RasterFormatException(Messages.getString("awt.22E")); //$NON-NLS-1$
}
if (location == null) {
location = new Point(0, 0);
}
if ((long)location.x + w > Integer.MAX_VALUE || (long)location.y + h > Integer.MAX_VALUE) {
// awt.276=location.x + w or location.y + h results in integer
// overflow
throw new RasterFormatException(Messages.getString("awt.276")); //$NON-NLS-1$
}
if (dataBuffer == null) {
// awt.278=dataBuffer is null
throw new NullPointerException(Messages.getString("awt.278")); //$NON-NLS-1$
}
int dataType = dataBuffer.getDataType();
if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_USHORT) {
// awt.230=dataType is not one of the supported data types
throw new IllegalArgumentException(Messages.getString("awt.230")); //$NON-NLS-1$
}
if (dataBuffer.getNumBanks() > 1) {
// awt.27A=dataBuffer has more than one bank
throw new RasterFormatException(Messages.getString("awt.27A")); //$NON-NLS-1$
}
if (bandOffsets == null) {
// awt.27B=bandOffsets is null
throw new NullPointerException(Messages.getString("awt.27B")); //$NON-NLS-1$
}
PixelInterleavedSampleModel sampleModel = new PixelInterleavedSampleModel(dataType, w, h,
pixelStride, scanlineStride, bandOffsets);
return new OrdinaryWritableRaster(sampleModel, dataBuffer, location);
| public static java.awt.image.WritableRaster | createInterleavedRaster(int dataType, int w, int h, int scanlineStride, int pixelStride, int[] bandOffsets, java.awt.Point location)Creates a Raster object with a PixelInterleavedSampleModel and the
specified data type. The Data type can be one of the following values:
TYPE_BYTE, TYPE_USHORT, or TYPE_INT.
if (w <= 0 || h <= 0) {
// awt.22E=w or h is less than or equal to zero
throw new RasterFormatException(Messages.getString("awt.22E")); //$NON-NLS-1$
}
if (location == null) {
location = new Point(0, 0);
}
if ((long)location.x + w > Integer.MAX_VALUE || (long)location.y + h > Integer.MAX_VALUE) {
// awt.276=location.x + w or location.y + h results in integer
// overflow
throw new RasterFormatException(Messages.getString("awt.276")); //$NON-NLS-1$
}
if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_USHORT) {
// awt.230=dataType is not one of the supported data types
throw new IllegalArgumentException(Messages.getString("awt.230")); //$NON-NLS-1$
}
if (bandOffsets == null) {
// awt.27B=bandOffsets is null
throw new NullPointerException(Messages.getString("awt.27B")); //$NON-NLS-1$
}
int minOffset = bandOffsets[0];
for (int i = 1; i < bandOffsets.length; i++) {
if (bandOffsets[i] < minOffset) {
minOffset = bandOffsets[i];
}
}
int size = (h - 1) * scanlineStride + w * pixelStride + minOffset;
DataBuffer data = null;
switch (dataType) {
case DataBuffer.TYPE_BYTE:
data = new DataBufferByte(size);
break;
case DataBuffer.TYPE_USHORT:
data = new DataBufferUShort(size);
break;
}
return createInterleavedRaster(data, w, h, scanlineStride, pixelStride, bandOffsets,
location);
| public static java.awt.image.WritableRaster | createInterleavedRaster(int dataType, int w, int h, int bands, java.awt.Point location)Creates a Raster object with a PixelInterleavedSampleModel and the
specified data type. The Data type can be one of the following values:
TYPE_BYTE, TYPE_USHORT, or TYPE_INT.
if (w <= 0 || h <= 0) {
// awt.22E=w or h is less than or equal to zero
throw new RasterFormatException(Messages.getString("awt.22E")); //$NON-NLS-1$
}
if (location == null) {
location = new Point(0, 0);
}
if ((long)location.x + w > Integer.MAX_VALUE || (long)location.y + h > Integer.MAX_VALUE) {
// awt.276=location.x + w or location.y + h results in integer
// overflow
throw new RasterFormatException(Messages.getString("awt.276")); //$NON-NLS-1$
}
if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_USHORT) {
// awt.230=dataType is not one of the supported data types
throw new IllegalArgumentException(Messages.getString("awt.230")); //$NON-NLS-1$
}
int bandOffsets[] = new int[bands];
for (int i = 0; i < bands; i++) {
bandOffsets[i] = i;
}
return createInterleavedRaster(dataType, w, h, w * bands, bands, bandOffsets, location);
| public static java.awt.image.WritableRaster | createPackedRaster(int dataType, int w, int h, int[] bandMasks, java.awt.Point location)Creates a Raster object with a SinglePixelPackedSampleModel and the
specified DataBuffer.
if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_USHORT
&& dataType != DataBuffer.TYPE_INT) {
// awt.230=dataType is not one of the supported data types
throw new IllegalArgumentException(Messages.getString("awt.230")); //$NON-NLS-1$
}
if (w <= 0 || h <= 0) {
// awt.22E=w or h is less than or equal to zero
throw new RasterFormatException(Messages.getString("awt.22E")); //$NON-NLS-1$
}
if (location == null) {
location = new Point(0, 0);
}
if ((long)location.x + w > Integer.MAX_VALUE || (long)location.y + h > Integer.MAX_VALUE) {
// awt.276=location.x + w or location.y + h results in integer
// overflow
throw new RasterFormatException(Messages.getString("awt.276")); //$NON-NLS-1$
}
if (bandMasks == null) {
// awt.27C=bandMasks is null
throw new NullPointerException(Messages.getString("awt.27C")); //$NON-NLS-1$
}
DataBuffer data = null;
switch (dataType) {
case DataBuffer.TYPE_BYTE:
data = new DataBufferByte(w * h);
break;
case DataBuffer.TYPE_USHORT:
data = new DataBufferUShort(w * h);
break;
case DataBuffer.TYPE_INT:
data = new DataBufferInt(w * h);
break;
}
return createPackedRaster(data, w, h, w, bandMasks, location);
| public static java.awt.image.WritableRaster | createPackedRaster(java.awt.image.DataBuffer dataBuffer, int w, int h, int scanlineStride, int[] bandMasks, java.awt.Point location)Creates a Raster object with a SinglePixelPackedSampleModel and the
specified DataBuffer.
if (dataBuffer == null) {
// awt.278=dataBuffer is null
throw new NullPointerException(Messages.getString("awt.278")); //$NON-NLS-1$
}
if (w <= 0 || h <= 0) {
// awt.22E=w or h is less than or equal to zero
throw new RasterFormatException(Messages.getString("awt.22E")); //$NON-NLS-1$
}
if (location == null) {
location = new Point(0, 0);
}
if ((long)location.x + w > Integer.MAX_VALUE || (long)location.y + h > Integer.MAX_VALUE) {
// awt.276=location.x + w or location.y + h results in integer
// overflow
throw new RasterFormatException(Messages.getString("awt.276")); //$NON-NLS-1$
}
if (bandMasks == null) {
// awt.27C=bandMasks is null
throw new RasterFormatException(Messages.getString("awt.27C")); //$NON-NLS-1$
}
if (dataBuffer.getNumBanks() > 1) {
// awt.27A=dataBuffer has more than one bank
throw new RasterFormatException(Messages.getString("awt.27A")); //$NON-NLS-1$
}
int dataType = dataBuffer.getDataType();
if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_USHORT
&& dataType != DataBuffer.TYPE_INT) {
// awt.230=dataType is not one of the supported data types
throw new IllegalArgumentException(Messages.getString("awt.230")); //$NON-NLS-1$
}
SinglePixelPackedSampleModel sampleModel = new SinglePixelPackedSampleModel(dataType, w, h,
scanlineStride, bandMasks);
return new OrdinaryWritableRaster(sampleModel, dataBuffer, location);
| public static java.awt.image.WritableRaster | createPackedRaster(java.awt.image.DataBuffer dataBuffer, int w, int h, int bitsPerPixel, java.awt.Point location)Creates a Raster object with a MultiPixelPackedSampleModel and the
specified DataBuffer.
if (w <= 0 || h <= 0) {
// awt.22E=w or h is less than or equal to zero
throw new RasterFormatException(Messages.getString("awt.22E")); //$NON-NLS-1$
}
if (location == null) {
location = new Point(0, 0);
}
if ((long)location.x + w > Integer.MAX_VALUE || (long)location.y + h > Integer.MAX_VALUE) {
// awt.276=location.x + w or location.y + h results in integer
// overflow
throw new RasterFormatException(Messages.getString("awt.276")); //$NON-NLS-1$
}
if (dataBuffer == null) {
// awt.278=dataBuffer is null
throw new NullPointerException(Messages.getString("awt.278")); //$NON-NLS-1$
}
if (dataBuffer.getNumBanks() > 1) {
// awt.27A=dataBuffer has more than one bank
throw new RasterFormatException(Messages.getString("awt.27A")); //$NON-NLS-1$
}
int dataType = dataBuffer.getDataType();
if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_USHORT
&& dataType != DataBuffer.TYPE_INT) {
// awt.230=dataType is not one of the supported data types
throw new IllegalArgumentException(Messages.getString("awt.230")); //$NON-NLS-1$
}
MultiPixelPackedSampleModel sampleModel = new MultiPixelPackedSampleModel(dataType, w, h,
bitsPerPixel);
return new OrdinaryWritableRaster(sampleModel, dataBuffer, location);
| public static java.awt.image.WritableRaster | createPackedRaster(int dataType, int w, int h, int bands, int bitsPerBand, java.awt.Point location)Creates a Raster object with a MultiPixelPackedSampleModel and the
specified DataBuffer.
if (w <= 0 || h <= 0) {
// awt.22E=w or h is less than or equal to zero
throw new RasterFormatException(Messages.getString("awt.22E")); //$NON-NLS-1$
}
if (location == null) {
location = new Point(0, 0);
}
if ((long)location.x + w > Integer.MAX_VALUE || (long)location.y + h > Integer.MAX_VALUE) {
// awt.276=location.x + w or location.y + h results in integer
// overflow
throw new RasterFormatException(Messages.getString("awt.276")); //$NON-NLS-1$
}
if (bands < 1 || bitsPerBand < 1) {
// awt.27D=bitsPerBand or bands is not greater than zero
throw new IllegalArgumentException(Messages.getString("awt.27D")); //$NON-NLS-1$
}
if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_USHORT
&& dataType != DataBuffer.TYPE_INT) {
// awt.230=dataType is not one of the supported data types
throw new IllegalArgumentException(Messages.getString("awt.230")); //$NON-NLS-1$
}
if (bitsPerBand * bands > DataBuffer.getDataTypeSize(dataType)) {
// awt.27E=The product of bitsPerBand and bands is greater than the
// number of bits held by dataType
throw new IllegalArgumentException(Messages.getString("awt.27E")); //$NON-NLS-1$
}
if (bands > 1) {
int bandMasks[] = new int[bands];
int mask = (1 << bitsPerBand) - 1;
for (int i = 0; i < bands; i++) {
bandMasks[i] = mask << (bitsPerBand * (bands - 1 - i));
}
return createPackedRaster(dataType, w, h, bandMasks, location);
}
DataBuffer data = null;
int size = ((bitsPerBand * w + DataBuffer.getDataTypeSize(dataType) - 1) / DataBuffer
.getDataTypeSize(dataType))
* h;
switch (dataType) {
case DataBuffer.TYPE_BYTE:
data = new DataBufferByte(size);
break;
case DataBuffer.TYPE_USHORT:
data = new DataBufferUShort(size);
break;
case DataBuffer.TYPE_INT:
data = new DataBufferInt(size);
break;
}
return createPackedRaster(data, w, h, bitsPerBand, location);
| public static java.awt.image.Raster | createRaster(java.awt.image.SampleModel sm, java.awt.image.DataBuffer db, java.awt.Point location)Creates a Raster object with the specified DataBuffer and SampleModel.
if (sm == null || db == null) {
// awt.27F=SampleModel or DataBuffer is null
throw new NullPointerException(Messages.getString("awt.27F")); //$NON-NLS-1$
}
if (location == null) {
location = new Point(0, 0);
}
return new Raster(sm, db, location);
| public java.awt.image.Raster | createTranslatedChild(int childMinX, int childMinY)Creates the translated child of this Raster. The New Raster object is a
reference to the this Raster with a different location.
return createChild(minX, minY, width, height, childMinX, childMinY, null);
| public static java.awt.image.WritableRaster | createWritableRaster(java.awt.image.SampleModel sm, java.awt.image.DataBuffer db, java.awt.Point location)Creates a WritableRaster with the specified SampleModel and DataBuffer.
if (sm == null || db == null) {
// awt.27F=SampleModel or DataBuffer is null
throw new NullPointerException(Messages.getString("awt.27F")); //$NON-NLS-1$
}
if (location == null) {
location = new Point(0, 0);
}
return new OrdinaryWritableRaster(sm, db, location);
| public static java.awt.image.WritableRaster | createWritableRaster(java.awt.image.SampleModel sm, java.awt.Point location)Creates a WritableRaster with the specified SampleModel.
if (sm == null) {
// awt.280=SampleModel is null
throw new NullPointerException(Messages.getString("awt.280")); //$NON-NLS-1$
}
if (location == null) {
location = new Point(0, 0);
}
return createWritableRaster(sm, sm.createDataBuffer(), location);
| public java.awt.Rectangle | getBounds()Gets the bounds of this Raster as a rectangle.
return new Rectangle(minX, minY, width, height);
| public java.awt.image.DataBuffer | getDataBuffer()Gets the DataBuffer associated with this Raster.
return dataBuffer;
| public java.lang.Object | getDataElements(int x, int y, int w, int h, java.lang.Object outData)Gets the data elements which represent the pixel data of the specified
rectangle area as a primitive array. The following image data types are
supported: DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT,
DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT, DataBuffer.TYPE_FLOAT, or
DataBuffer.TYPE_DOUBLE.
return sampleModel.getDataElements(x - sampleModelTranslateX, y - sampleModelTranslateY, w,
h, outData, dataBuffer);
| public java.lang.Object | getDataElements(int x, int y, java.lang.Object outData)Gets the data elements which represent the specified pixel of this Raster
as a primitive array. The following image data types are supported:
DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, DataBuffer.TYPE_INT,
DataBuffer.TYPE_SHORT, DataBuffer.TYPE_FLOAT, or DataBuffer.TYPE_DOUBLE.
return sampleModel.getDataElements(x - sampleModelTranslateX, y - sampleModelTranslateY,
outData, dataBuffer);
| public final int | getHeight()Gets the height of this Raster.
return height;
| public final int | getMinX()Gets the minimum X coordinate of this Raster.
return minX;
| public final int | getMinY()Gets the minimum Y coordinate of this Raster.
return minY;
| public final int | getNumBands()Gets the number of bands in this Raster.
return numBands;
| public final int | getNumDataElements()Gets the number of data elements for one pixel.
return numDataElements;
| public java.awt.image.Raster | getParent()Gets the parent Raster for this Raster object.
return parent;
| public double[] | getPixel(int x, int y, double[] dArray)Gets a double array of samples for the specified pixel in this Raster.
return sampleModel.getPixel(x - sampleModelTranslateX, y - sampleModelTranslateY, dArray,
dataBuffer);
| public float[] | getPixel(int x, int y, float[] fArray)Gets a float array of samples for the specified pixel in this Raster.
return sampleModel.getPixel(x - sampleModelTranslateX, y - sampleModelTranslateY, fArray,
dataBuffer);
| public int[] | getPixel(int x, int y, int[] iArray)Gets an integer array of samples for the specified pixel in this Raster.
return sampleModel.getPixel(x - sampleModelTranslateX, y - sampleModelTranslateY, iArray,
dataBuffer);
| public double[] | getPixels(int x, int y, int w, int h, double[] dArray)Gets an double array of samples for the specified rectangular area of
pixels in this Raster.
return sampleModel.getPixels(x - sampleModelTranslateX, y - sampleModelTranslateY, w, h,
dArray, dataBuffer);
| public float[] | getPixels(int x, int y, int w, int h, float[] fArray)Gets an float array of samples for the specified rectangular area of
pixels in this Raster.
return sampleModel.getPixels(x - sampleModelTranslateX, y - sampleModelTranslateY, w, h,
fArray, dataBuffer);
| public int[] | getPixels(int x, int y, int w, int h, int[] iArray)Gets an integer array of samples for the specified rectangular area of
pixels in this raster.
return sampleModel.getPixels(x - sampleModelTranslateX, y - sampleModelTranslateY, w, h,
iArray, dataBuffer);
| public int | getSample(int x, int y, int b)Gets the sample for the specified band of the specified pixel as an
integer.
return sampleModel.getSample(x - sampleModelTranslateX, y - sampleModelTranslateY, b,
dataBuffer);
| public double | getSampleDouble(int x, int y, int b)Gets the sample for the specified band of the specified pixel as a
double.
return sampleModel.getSampleDouble(x - sampleModelTranslateX, y - sampleModelTranslateY, b,
dataBuffer);
| public float | getSampleFloat(int x, int y, int b)Gets the sample for the specified band of the specified pixel as a float.
return sampleModel.getSampleFloat(x - sampleModelTranslateX, y - sampleModelTranslateY, b,
dataBuffer);
| public java.awt.image.SampleModel | getSampleModel()Gets the SampleModel associated with this Raster.
return sampleModel;
| public final int | getSampleModelTranslateX()Gets the translation of the X coordinate from the SampleModel coordinate
system to the Rasters's coordinate system.
return sampleModelTranslateX;
| public final int | getSampleModelTranslateY()Gets the translation of the Y coordinate from the SampleModel coordinate
system to the Rasters's coordinate system.
return sampleModelTranslateY;
| public double[] | getSamples(int x, int y, int w, int h, int b, double[] dArray)Gets the double array of samples for the specified band of the specified
rectangular area of pixels in this Raster as a double array.
return sampleModel.getSamples(x - sampleModelTranslateX, y - sampleModelTranslateY, w, h,
b, dArray, dataBuffer);
| public float[] | getSamples(int x, int y, int w, int h, int b, float[] fArray)Gets the float array of samples for the specified band of the specified
rectangular area of pixels in this Raster as a float array.
return sampleModel.getSamples(x - sampleModelTranslateX, y - sampleModelTranslateY, w, h,
b, fArray, dataBuffer);
| public int[] | getSamples(int x, int y, int w, int h, int b, int[] iArray)Gets the integer array of samples for the specified band of the specified
rectangular area of pixels in this Raster as a integer array.
return sampleModel.getSamples(x - sampleModelTranslateX, y - sampleModelTranslateY, w, h,
b, iArray, dataBuffer);
| public final int | getTransferType()Gets the transfer type for pixels of this Raster.
return sampleModel.getTransferType();
| public final int | getWidth()Gets the width of this Raster.
return width;
| private static void | validateDataBuffer(java.awt.image.DataBuffer dataBuffer, int w, int h, int scanlineStride)Validate data buffer.
if (dataBuffer.getSize() < (scanlineStride * (h - 1) + w - 1)) {
// awt.298=dataBuffer is too small
throw new RasterFormatException(Messages.getString("awt.298")); //$NON-NLS-1$
}
|
|