public class WritableRaster extends Raster
The constructors of this class are protected. To instantiate a WritableRaster, use one of the createWritableRaster factory methods in the Raster class.
dataBuffer, height, minX, minY, numBands, numDataElements, parent, sampleModel, sampleModelTranslateX, sampleModelTranslateY, width
Modifier | Constructor and Description |
---|---|
protected |
WritableRaster(SampleModel sampleModel,
DataBuffer dataBuffer,
Point origin)
Constructs a WritableRaster with the given SampleModel and DataBuffer.
|
protected |
WritableRaster(SampleModel sampleModel,
DataBuffer dataBuffer,
Rectangle aRegion,
Point sampleModelTranslate,
WritableRaster parent)
Constructs a WritableRaster with the given SampleModel, DataBuffer,
and parent.
|
protected |
WritableRaster(SampleModel sampleModel,
Point origin)
Constructs a WritableRaster with the given SampleModel.
|
Modifier and Type | Method and Description |
---|---|
WritableRaster |
createWritableChild(int parentX,
int parentY,
int w,
int h,
int childMinX,
int childMinY,
int[] bandList)
Returns a new WritableRaster which shares all or part of this
WritableRaster's DataBuffer.
|
WritableRaster |
createWritableTranslatedChild(int childMinX,
int childMinY)
Create a WritableRaster with the same size, SampleModel and DataBuffer
as this one, but with a different location.
|
WritableRaster |
getWritableParent()
Returns the parent WritableRaster (if any) of this WritableRaster,
or else null.
|
void |
setDataElements(int x,
int y,
int w,
int h,
Object inData)
Sets the data for a rectangle of pixels from a
primitive array of type TransferType.
|
void |
setDataElements(int x,
int y,
Object inData)
Sets the data for a single pixel from a
primitive array of type TransferType.
|
void |
setDataElements(int x,
int y,
Raster inRaster)
Sets the data for a rectangle of pixels from an input Raster.
|
void |
setPixel(int x,
int y,
double[] dArray)
Sets a pixel in the DataBuffer using a double array of samples for input.
|
void |
setPixel(int x,
int y,
float[] fArray)
Sets a pixel in the DataBuffer using a float array of samples for input.
|
void |
setPixel(int x,
int y,
int[] iArray)
Sets a pixel in the DataBuffer using an int array of samples for input.
|
void |
setPixels(int x,
int y,
int w,
int h,
double[] dArray)
Sets all samples for a rectangle of pixels from a double array containing
one sample per array element.
|
void |
setPixels(int x,
int y,
int w,
int h,
float[] fArray)
Sets all samples for a rectangle of pixels from a float array containing
one sample per array element.
|
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.
|
void |
setRect(int dx,
int dy,
Raster srcRaster)
Copies pixels from Raster srcRaster to this WritableRaster.
|
void |
setRect(Raster srcRaster)
Copies pixels from Raster srcRaster to this WritableRaster.
|
void |
setSample(int x,
int y,
int b,
double s)
Sets a sample in the specified band for the pixel located at (x,y)
in the DataBuffer using a double for input.
|
void |
setSample(int x,
int y,
int b,
float s)
Sets a sample in the specified band for the pixel located at (x,y)
in the DataBuffer using a float for input.
|
void |
setSample(int x,
int y,
int b,
int s)
Sets a sample in the specified band for the pixel located at (x,y)
in the DataBuffer using an int for input.
|
void |
setSamples(int x,
int y,
int w,
int h,
int b,
double[] dArray)
Sets the samples in the specified band for the specified rectangle
of pixels from a double array containing one sample per array element.
|
void |
setSamples(int x,
int y,
int w,
int h,
int b,
float[] fArray)
Sets the samples in the specified band for the specified rectangle
of pixels from a float array containing one sample per array element.
|
void |
setSamples(int x,
int y,
int w,
int h,
int b,
int[] iArray)
Sets the samples in the specified band for the specified rectangle
of pixels from an int array containing one sample per array element.
|
createBandedRaster, createBandedRaster, createBandedRaster, createChild, createCompatibleWritableRaster, createCompatibleWritableRaster, createCompatibleWritableRaster, createCompatibleWritableRaster, createInterleavedRaster, createInterleavedRaster, createInterleavedRaster, createPackedRaster, createPackedRaster, createPackedRaster, createPackedRaster, createRaster, createTranslatedChild, createWritableRaster, createWritableRaster, getBounds, getDataBuffer, getDataElements, getDataElements, getHeight, getMinX, getMinY, getNumBands, getNumDataElements, getParent, getPixel, getPixel, getPixel, getPixels, getPixels, getPixels, getSample, getSampleDouble, getSampleFloat, getSampleModel, getSampleModelTranslateX, getSampleModelTranslateY, getSamples, getSamples, getSamples, getTransferType, getWidth
protected WritableRaster(SampleModel sampleModel, Point origin)
sampleModel
- The SampleModel that specifies the layout.origin
- The Point that specifies the origin.RasterFormatException
- if computing either
origin.x + sampleModel.getWidth()
or
origin.y + sampleModel.getHeight()
results
in integer overflowprotected WritableRaster(SampleModel sampleModel, DataBuffer dataBuffer, Point origin)
sampleModel
- The SampleModel that specifies the layout.dataBuffer
- The DataBuffer that contains the image data.origin
- The Point that specifies the origin.RasterFormatException
- if computing either
origin.x + sampleModel.getWidth()
or
origin.y + sampleModel.getHeight()
results
in integer overflowprotected WritableRaster(SampleModel sampleModel, DataBuffer dataBuffer, Rectangle aRegion, Point sampleModelTranslate, WritableRaster parent)
sampleModel
- The SampleModel that specifies the layout.dataBuffer
- The DataBuffer that contains the image data.aRegion
- The Rectangle that specifies the image area.sampleModelTranslate
- The Point that specifies the translation
from SampleModel to Raster coordinates.parent
- The parent (if any) of this raster.RasterFormatException
- if aRegion
has width
or height less than or equal to zero, or computing either
aRegion.x + aRegion.width
or
aRegion.y + aRegion.height
results in integer
overflowpublic WritableRaster getWritableParent()
WritableRaster
, or
null
.public WritableRaster createWritableTranslatedChild(int childMinX, int childMinY)
childMinX
- X coord of the upper left corner of the new Raster.childMinY
- Y coord of the upper left corner of the new Raster.WritableRaster
the same as this one except
for the specified location.RasterFormatException
- if computing either
childMinX + this.getWidth()
or
childMinY + this.getHeight()
results in integer
overflowpublic WritableRaster createWritableChild(int parentX, int parentY, int w, int h, int childMinX, int childMinY, int[] bandList)
The parentX, parentY, width and height parameters form a Rectangle in this WritableRaster's coordinate space, indicating the area of pixels to be shared. An error will be thrown if this Rectangle is not contained with the bounds of the current WritableRaster.
The new WritableRaster may additionally be translated to a different coordinate system for the plane than that used by the current WritableRaster. The childMinX and childMinY parameters give the new (x, y) coordinate of the upper-left pixel of the returned WritableRaster; the coordinate (childMinX, childMinY) in the new WritableRaster will map to the same pixel as the coordinate (parentX, parentY) in the current WritableRaster.
The new WritableRaster may be defined to contain only a subset of the bands of the current WritableRaster, possibly reordered, by means of the bandList parameter. If bandList is null, it is taken to include all of the bands of the current WritableRaster in their current order.
To create a new WritableRaster that contains a subregion of the current WritableRaster, but shares its coordinate system and bands, this method should be called with childMinX equal to parentX, childMinY equal to parentY, and bandList equal to null.
parentX
- X coordinate of the upper left corner in this
WritableRaster's coordinates.parentY
- Y coordinate of the upper left corner in this
WritableRaster's coordinates.w
- Width of the region starting at (parentX, parentY).h
- Height of the region starting at (parentX, parentY).childMinX
- X coordinate of the upper left corner of
the returned WritableRaster.childMinY
- Y coordinate of the upper left corner of
the returned WritableRaster.bandList
- Array of band indices, or null to use all bands.WritableRaster
sharing all or part of the
DataBuffer
of this WritableRaster
.RasterFormatException
- if the subregion is outside of the
raster bounds.RasterFormatException
- if w
or
h
is less than or equal to zero, or computing any of
parentX + w
, parentY + h
,
childMinX + w
, or
childMinY + h
results in integer
overflowpublic void setDataElements(int x, int y, Object inData)
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.ArrayIndexOutOfBoundsException
- if the coordinates are not
in bounds, or if inData is too small to hold the input.SampleModel.setDataElements(int, int, Object, DataBuffer)
public void setDataElements(int x, int y, Raster inRaster)
x
- The X coordinate of the pixel location.y
- The Y coordinate of the pixel location.inRaster
- Raster containing data to place at x,y.NullPointerException
- if inRaster is null.ArrayIndexOutOfBoundsException
- if the coordinates are not
in bounds.public void setDataElements(int x, int y, int w, int h, Object inData)
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+w-1, y+h-1.NullPointerException
- if inData is null.ArrayIndexOutOfBoundsException
- if the coordinates are not
in bounds, or if inData is too small to hold the input.SampleModel.setDataElements(int, int, int, int, Object, DataBuffer)
public void setRect(Raster srcRaster)
If all samples of both source and destination Rasters are of
integral type and less than or equal to 32 bits in size, then calling
this method is equivalent to executing the following code for all
x,y
addresses valid in both Rasters.
Raster srcRaster; WritableRaster dstRaster; for (int b = 0; b < srcRaster.getNumBands(); b++) { dstRaster.setSample(x, y, b, srcRaster.getSample(x, y, b)); }Thus, when copying an integral type source to an integral type destination, if the source sample size is greater than the destination sample size for a particular band, the high order bits of the source sample are truncated. If the source sample size is less than the destination size for a particular band, the high order bits of the destination are zero-extended or sign-extended depending on whether srcRaster's SampleModel treats the sample as a signed or unsigned quantity.
When copying a float or double source to an integral type destination, each source sample is cast to the destination type. When copying an integral type source to a float or double destination, the source is first converted to a 32-bit int (if necessary), using the above rules for integral types, and then the int is cast to float or double.
srcRaster
- The Raster from which to copy pixels.NullPointerException
- if srcRaster is null.public void setRect(int dx, int dy, Raster srcRaster)
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.NullPointerException
- if srcRaster is null.public void setPixel(int x, int y, int[] iArray)
x
- The X coordinate of the pixel location.y
- The Y coordinate of the pixel location.iArray
- The input samples in a int array.NullPointerException
- if iArray is null.ArrayIndexOutOfBoundsException
- if the coordinates are not
in bounds, or if iArray is too small to hold the input.public void setPixel(int x, int y, float[] fArray)
x
- The X coordinate of the pixel location.y
- The Y coordinate of the pixel location.fArray
- The input samples in a float array.NullPointerException
- if fArray is null.ArrayIndexOutOfBoundsException
- if the coordinates are not
in bounds, or if fArray is too small to hold the input.public void setPixel(int x, int y, double[] dArray)
x
- The X coordinate of the pixel location.y
- The Y coordinate of the pixel location.dArray
- The input samples in a double array.NullPointerException
- if dArray is null.ArrayIndexOutOfBoundsException
- if the coordinates are not
in bounds, or if dArray is too small to hold the input.public void setPixels(int x, int y, int w, int h, int[] iArray)
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.NullPointerException
- if iArray is null.ArrayIndexOutOfBoundsException
- if the coordinates are not
in bounds, or if iArray is too small to hold the input.public void setPixels(int x, int y, int w, int h, float[] fArray)
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.fArray
- The input float pixel array.NullPointerException
- if fArray is null.ArrayIndexOutOfBoundsException
- if the coordinates are not
in bounds, or if fArray is too small to hold the input.public void setPixels(int x, int y, int w, int h, double[] dArray)
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.dArray
- The input double pixel array.NullPointerException
- if dArray is null.ArrayIndexOutOfBoundsException
- if the coordinates are not
in bounds, or if dArray is too small to hold the input.public void setSample(int x, int y, int b, int s)
x
- The X coordinate of the pixel location.y
- The Y coordinate of the pixel location.b
- The band to set.s
- The input sample.ArrayIndexOutOfBoundsException
- if the coordinates or
the band index are not in bounds.public void setSample(int x, int y, int b, float s)
x
- The X coordinate of the pixel location.y
- The Y coordinate of the pixel location.b
- The band to set.s
- The input sample as a float.ArrayIndexOutOfBoundsException
- if the coordinates or
the band index are not in bounds.public void setSample(int x, int y, int b, double s)
x
- The X coordinate of the pixel location.y
- The Y coordinate of the pixel location.b
- The band to set.s
- The input sample as a double.ArrayIndexOutOfBoundsException
- if the coordinates or
the band index are not in bounds.public void setSamples(int x, int y, int w, int h, int b, int[] iArray)
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.b
- The band to set.iArray
- The input int sample array.NullPointerException
- if iArray is null.ArrayIndexOutOfBoundsException
- if the coordinates or
the band index are not in bounds, or if iArray is too small to
hold the input.public void setSamples(int x, int y, int w, int h, int b, float[] fArray)
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.b
- The band to set.fArray
- The input float sample array.NullPointerException
- if fArray is null.ArrayIndexOutOfBoundsException
- if the coordinates or
the band index are not in bounds, or if fArray is too small to
hold the input.public void setSamples(int x, int y, int w, int h, int b, double[] dArray)
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.b
- The band to set.dArray
- The input double sample array.NullPointerException
- if dArray is null.ArrayIndexOutOfBoundsException
- if the coordinates or
the band index are not in bounds, or if dArray is too small to
hold the input. Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2015, Oracle and/or its affiliates. All rights reserved.