Subclasses of WritableRaster that are instantiated via the
protected constructors may only accept DataBuffer
and SampleModel
system instances, those created internally
and returned using accessor method calls such as,
Raster.getDataBuffer()
and BufferedImage.getSampleModel()
. Instances
of DataBuffer
and SampleModel
created directly through
invocation of the SampleModel
and DataBuffer
constuctors
when passed in to the protected constructors will result in an
IllegalArgumentException.
Fields inherited from class java.awt.image.Raster |
dataBuffer, height, minX, minY, numBands, numDataElements, parent, sampleModel, sampleModelTranslateX, sampleModelTranslateY, width |
Method Summary |
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 |
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. |
Methods inherited from class java.awt.image.Raster |
createChild, getBounds, getDataBuffer, getHeight, getNumBands, getParent, getPixels, getSampleModel, getSampleModelTranslateX, getSampleModelTranslateY, getSamples, getWidth |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WritableRaster
protected WritableRaster(SampleModel sampleModel,
DataBuffer dataBuffer,
Point origin)
- Constructs a WritableRaster with the given SampleModel and DataBuffer.
The WritableRaster's upper left corner is origin and it is the same
size as the SampleModel. The DataBuffer is not initialized and must
be compatible with SampleModel.
- Parameters:
sampleModel
- The SampleModel that specifies the layout.dataBuffer
- The DataBuffer that contains the image data.origin
- The Point that specifies the origin.
- Throws:
RasterFormatException
- if computing either
origin.x + sampleModel.getWidth()
or
origin.y + sampleModel.getHeight()
results
in integer overflow
java.lang.IllegalArgumentException
- for
instances of SampleModel
and
DataBuffer
created directly through the invocation
of the DataBuffer
and SampleModel
constructors.
WritableRaster
protected WritableRaster(SampleModel sampleModel,
DataBuffer dataBuffer,
Rectangle aRegion,
Point sampleModelTranslate,
WritableRaster parent)
- Constructs a WritableRaster with the given SampleModel, DataBuffer,
and parent. aRegion specifies the bounding rectangle of the new
Raster. When translated into the base Raster's coordinate
system, aRegion must be contained by the base Raster.
(The base Raster is the Raster's ancestor which has no parent.)
sampleModelTranslate specifies the sampleModelTranslateX and
sampleModelTranslateY values of the new Raster.
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.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.
- Throws:
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
overflow
java.lang.IllegalArgumentException
- for
instances of SampleModel
and
DataBuffer
created directly through the invocation
of the DataBuffer
and SampleModel
constructors.
setRect
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. For details, see
WritableRaster#setRect(Raster)
.
- Parameters:
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.
- Throws:
java.lang.NullPointerException
- if srcRaster is null.
setPixels
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.
An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
However, explicit bounds checking is not guaranteed.
- 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.iArray
- The input int pixel array.
- Throws:
java.lang.NullPointerException
- if iArray is null.
java.lang.ArrayIndexOutOfBoundsException
- if the coordinates are not
in bounds, or if iArray is too small to hold the input.
setSamples
public 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.
An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
However, explicit bounds checking is not guaranteed.
- 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.b
- The band to set.iArray
- The input int sample array.
- Throws:
java.lang.NullPointerException
- if iArray is null.
java.lang.ArrayIndexOutOfBoundsException
- if the coordinates or
the band index are not in bounds, or if iArray is too small to
hold the input.
Java and Java 2D are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
Copyright 1993 - 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All Rights Reserved.
Use of this specification is subject to this license.