public class Raster extends Object
DataBuffer
which
stores the pixel values, and a SampleModel
which is used to retrieve
the pixel values.Modifier and Type | Field and Description |
---|---|
protected DataBuffer |
dataBuffer
The data buffer used to store the pixel values.
|
protected int |
height
The height of the raster.
|
protected int |
minX
The x-coordinate of the top left corner of the raster.
|
protected int |
minY
The y-coordinate of the top left corner of the raster.
|
protected int |
numBands
The number of bands.
|
protected int |
numDataElements |
protected Raster |
parent
The raster's parent.
|
protected SampleModel |
sampleModel
The sample model used to access the pixel values.
|
protected int |
sampleModelTranslateX |
protected int |
sampleModelTranslateY |
protected int |
width
The width of the raster.
|
Modifier | Constructor and Description |
---|---|
protected |
Raster(SampleModel sampleModel,
DataBuffer dataBuffer,
Point origin)
Creates a new raster.
|
protected |
Raster(SampleModel sampleModel,
DataBuffer dataBuffer,
Rectangle aRegion,
Point sampleModelTranslate,
Raster parent)
Creates a new raster.
|
protected |
Raster(SampleModel sampleModel,
Point origin)
Creates a new raster.
|
Modifier and Type | Method and Description |
---|---|
static WritableRaster |
createBandedRaster(DataBuffer dataBuffer,
int w,
int h,
int scanlineStride,
int[] bankIndices,
int[] bandOffsets,
Point location)
Creates a new banded raster.
|
static WritableRaster |
createBandedRaster(int dataType,
int w,
int h,
int scanlineStride,
int[] bankIndices,
int[] bandOffsets,
Point location)
Creates a new banded raster.
|
static WritableRaster |
createBandedRaster(int dataType,
int w,
int h,
int bands,
Point location)
Creates a new banded raster.
|
Raster |
createChild(int parentX,
int parentY,
int width,
int height,
int childMinX,
int childMinY,
int[] bandList) |
WritableRaster |
createCompatibleWritableRaster()
Creates a new writable raster that is compatible with this raster.
|
WritableRaster |
createCompatibleWritableRaster(int w,
int h)
Creates a new writable raster that is compatible with this raster.
|
WritableRaster |
createCompatibleWritableRaster(int x,
int y,
int w,
int h)
Creates a new writable raster that is compatible with this raster, with
the specified bounds.
|
WritableRaster |
createCompatibleWritableRaster(Rectangle rect)
Creates a new writable raster that is compatible with this raster, with
the specified bounds.
|
static WritableRaster |
createInterleavedRaster(DataBuffer dataBuffer,
int w,
int h,
int scanlineStride,
int pixelStride,
int[] bandOffsets,
Point location)
Creates a new interleaved raster.
|
static WritableRaster |
createInterleavedRaster(int dataType,
int w,
int h,
int scanlineStride,
int pixelStride,
int[] bandOffsets,
Point location)
Creates an interleaved raster.
|
static WritableRaster |
createInterleavedRaster(int dataType,
int w,
int h,
int bands,
Point location)
Creates an interleaved raster using the specified data type.
|
static WritableRaster |
createPackedRaster(DataBuffer dataBuffer,
int w,
int h,
int scanlineStride,
int[] bandMasks,
Point location)
Creates a new packed raster.
|
static WritableRaster |
createPackedRaster(DataBuffer dataBuffer,
int w,
int h,
int bitsPerPixel,
Point location)
Creates a new packed raster.
|
static WritableRaster |
createPackedRaster(int dataType,
int w,
int h,
int[] bandMasks,
Point location)
Creates a new packed raster.
|
static WritableRaster |
createPackedRaster(int dataType,
int w,
int h,
int bands,
int bitsPerBand,
Point location)
Creates a new raster.
|
static Raster |
createRaster(SampleModel sm,
DataBuffer db,
Point location)
Creates a new raster.
|
Raster |
createTranslatedChild(int childMinX,
int childMinY) |
static WritableRaster |
createWritableRaster(SampleModel sm,
DataBuffer db,
Point location)
Creates a new writable raster.
|
static WritableRaster |
createWritableRaster(SampleModel sm,
Point location)
Creates a new writable raster.
|
Rectangle |
getBounds()
Returns a new rectangle containing the bounds of this raster.
|
DataBuffer |
getDataBuffer()
Returns the data buffer that stores the pixel data for this raster.
|
Object |
getDataElements(int x,
int y,
int w,
int h,
Object outData) |
Object |
getDataElements(int x,
int y,
Object outData) |
int |
getHeight()
Returns the height of the raster.
|
int |
getMinX()
Returns the x-coordinate of the top left corner of the raster.
|
int |
getMinY()
Returns the t-coordinate of the top left corner of the raster.
|
int |
getNumBands()
Returns the number of bands for this raster.
|
int |
getNumDataElements() |
Raster |
getParent()
Returns the raster's parent.
|
double[] |
getPixel(int x,
int y,
double[] dArray)
Returns an array containing the samples for the pixel at (x, y) in the
raster.
|
float[] |
getPixel(int x,
int y,
float[] fArray)
Returns an array containing the samples for the pixel at (x, y) in the
raster.
|
int[] |
getPixel(int x,
int y,
int[] iArray)
Returns an array containing the samples for the pixel at (x, y) in the
raster.
|
double[] |
getPixels(int x,
int y,
int w,
int h,
double[] dArray)
Returns an array containing the samples for the pixels in the region
specified by (x, y, w, h) in the raster.
|
float[] |
getPixels(int x,
int y,
int w,
int h,
float[] fArray)
Returns an array containing the samples for the pixels in the region
specified by (x, y, w, h) in the raster.
|
int[] |
getPixels(int x,
int y,
int w,
int h,
int[] iArray)
Returns an array containing the samples for the pixels in the region
specified by (x, y, w, h) in the raster.
|
int |
getSample(int x,
int y,
int b)
Returns the sample value for the pixel at (x, y) in the raster.
|
double |
getSampleDouble(int x,
int y,
int b)
Returns the sample value for the pixel at (x, y) in the raster.
|
float |
getSampleFloat(int x,
int y,
int b)
Returns the sample value for the pixel at (x, y) in the raster.
|
SampleModel |
getSampleModel()
Returns the sample model that accesses the data buffer (to extract pixel
data) for this raster.
|
int |
getSampleModelTranslateX()
Returns the x-translation.
|
int |
getSampleModelTranslateY()
Returns the y-translation.
|
double[] |
getSamples(int x,
int y,
int w,
int h,
int b,
double[] dArray)
Returns an array containing the samples from one band for the pixels in
the region specified by (x, y, w, h) in the raster.
|
float[] |
getSamples(int x,
int y,
int w,
int h,
int b,
float[] fArray)
Returns an array containing the samples from one band for the pixels in
the region specified by (x, y, w, h) in the raster.
|
int[] |
getSamples(int x,
int y,
int w,
int h,
int b,
int[] iArray)
Returns an array containing the samples from one band for the pixels in
the region specified by (x, y, w, h) in the raster.
|
int |
getTransferType()
Returns the transfer type for the raster (this is determined by the
raster's sample model).
|
int |
getWidth()
Returns the width of the raster.
|
String |
toString()
Create a String representing the state of this Raster.
|
protected SampleModel sampleModel
protected DataBuffer dataBuffer
protected int minX
protected int minY
protected int width
protected int height
protected int sampleModelTranslateX
protected int sampleModelTranslateY
protected int numBands
protected int numDataElements
protected Raster(SampleModel sampleModel, Point origin)
sampleModel
- the sample model.origin
- the origin.protected Raster(SampleModel sampleModel, DataBuffer dataBuffer, Point origin)
sampleModel
- the sample model.dataBuffer
- the data buffer.origin
- the origin.protected Raster(SampleModel sampleModel, DataBuffer dataBuffer, Rectangle aRegion, Point sampleModelTranslate, Raster parent)
sampleModel
- the sample model.dataBuffer
- the data buffer.aRegion
- the raster's bounds.sampleModelTranslate
- the translation (null
permitted).parent
- the raster's parent.public static WritableRaster createInterleavedRaster(int dataType, int w, int h, int bands, Point location)
dataType
- the data type.w
- the width.h
- the height.bands
- the number of bands.location
- public static WritableRaster createInterleavedRaster(int dataType, int w, int h, int scanlineStride, int pixelStride, int[] bandOffsets, Point location)
dataType
- the data type.w
- the width.h
- the height.scanlineStride
- the number of data elements from a sample on one
row to the corresponding sample on the next row.pixelStride
- the number of elements from a sample in one pixel to
the corresponding sample in the next pixel.bandOffsets
- the band offsets.location
- public static WritableRaster createBandedRaster(int dataType, int w, int h, int bands, Point location)
dataType
- the data type.w
- the width.h
- the height.bands
- the number of bands.location
- public static WritableRaster createBandedRaster(int dataType, int w, int h, int scanlineStride, int[] bankIndices, int[] bandOffsets, Point location)
dataType
- the data type.w
- the width.h
- the height.scanlineStride
- the number of data elements from a sample on one
row to the corresponding sample on the next row.bankIndices
- the index for each bank.bandOffsets
- the offset for each band.location
- public static WritableRaster createPackedRaster(int dataType, int w, int h, int[] bandMasks, Point location)
dataType
- the data type.w
- the width.h
- the height.bandMasks
- the bit mask for each band.location
- public static WritableRaster createPackedRaster(int dataType, int w, int h, int bands, int bitsPerBand, Point location)
dataType
- the data type.w
- the width.h
- the height.bands
- the number of bands.bitsPerBand
- the number of bits per band.location
- public static WritableRaster createInterleavedRaster(DataBuffer dataBuffer, int w, int h, int scanlineStride, int pixelStride, int[] bandOffsets, Point location)
dataBuffer
- the data buffer.w
- the width.h
- the height.scanlineStride
- the number of data elements from a sample on one
row to the corresponding sample on the next row.pixelStride
- the number of elements from a sample in one pixel to
the corresponding sample in the next pixel.bandOffsets
- the offset for each band.location
- public static WritableRaster createBandedRaster(DataBuffer dataBuffer, int w, int h, int scanlineStride, int[] bankIndices, int[] bandOffsets, Point location)
dataBuffer
- the data buffer.w
- the width.h
- the height.scanlineStride
- the number of data elements from a sample on one
row to the corresponding sample on the next row.bankIndices
- the index for each bank.bandOffsets
- the band offsets.location
- public static WritableRaster createPackedRaster(DataBuffer dataBuffer, int w, int h, int scanlineStride, int[] bandMasks, Point location)
dataBuffer
- the data buffer.w
- the width.h
- the height.scanlineStride
- the number of data elements from a sample on one
row to the corresponding sample on the next row.bandMasks
- the bit mask for each band.location
- public static WritableRaster createPackedRaster(DataBuffer dataBuffer, int w, int h, int bitsPerPixel, Point location)
dataBuffer
- the data buffer.w
- the width.h
- the height.bitsPerPixel
- the number of bits per pixel.location
- public static Raster createRaster(SampleModel sm, DataBuffer db, Point location)
sm
- the sample model.db
- the data buffer.location
- public static WritableRaster createWritableRaster(SampleModel sm, Point location)
sm
- the sample model.location
- public static WritableRaster createWritableRaster(SampleModel sm, DataBuffer db, Point location)
sm
- the sample model.db
- the data buffer.location
- public final int getSampleModelTranslateX()
public final int getSampleModelTranslateY()
public WritableRaster createCompatibleWritableRaster()
public WritableRaster createCompatibleWritableRaster(int w, int h)
w
- the width.h
- the height.public WritableRaster createCompatibleWritableRaster(Rectangle rect)
rect
- the raster bounds.public WritableRaster createCompatibleWritableRaster(int x, int y, int w, int h)
x
- the x-coordinate of the top-left corner of the raster.y
- the y-coordinate of the top-left corner of the raster.w
- the raster width.h
- the raster height.public Raster createTranslatedChild(int childMinX, int childMinY)
public Raster createChild(int parentX, int parentY, int width, int height, int childMinX, int childMinY, int[] bandList)
public Rectangle getBounds()
public final int getMinX()
public final int getMinY()
public final int getWidth()
public final int getHeight()
public final int getNumBands()
public final int getNumDataElements()
public final int getTransferType()
public DataBuffer getDataBuffer()
public SampleModel getSampleModel()
public Object getDataElements(int x, int y, Object outData)
public Object getDataElements(int x, int y, int w, int h, Object outData)
public int[] getPixel(int x, int y, int[] iArray)
iArray
is not null
, it will be
populated with the sample values and returned as the result of
this function (this avoids allocating a new array instance).x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.iArray
- an array to populate with the sample values and return as
the result (if null
, a new array will be allocated).public float[] getPixel(int x, int y, float[] fArray)
fArray
is not null
, it will be
populated with the sample values and returned as the result of
this function (this avoids allocating a new array instance).x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.fArray
- an array to populate with the sample values and return as
the result (if null
, a new array will be allocated).public double[] getPixel(int x, int y, double[] dArray)
dArray
is not null
, it will be
populated with the sample values and returned as the result of
this function (this avoids allocating a new array instance).x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.dArray
- an array to populate with the sample values and return as
the result (if null
, a new array will be allocated).public int[] getPixels(int x, int y, int w, int h, int[] iArray)
iArray
is not null
, it will be populated
with the sample values and returned as the result of this function (this
avoids allocating a new array instance).x
- the x-coordinate of the top-left pixel.y
- the y-coordinate of the top-left pixel.w
- the width of the region of pixels.h
- the height of the region of pixels.iArray
- an array to populate with the sample values and return as
the result (if null
, a new array will be allocated).public float[] getPixels(int x, int y, int w, int h, float[] fArray)
fArray
is not null
, it will be populated
with the sample values and returned as the result of this function (this
avoids allocating a new array instance).x
- the x-coordinate of the top-left pixel.y
- the y-coordinate of the top-left pixel.w
- the width of the region of pixels.h
- the height of the region of pixels.fArray
- an array to populate with the sample values and return as
the result (if null
, a new array will be allocated).public double[] getPixels(int x, int y, int w, int h, double[] dArray)
dArray
is not null
, it will be populated
with the sample values and returned as the result of this function (this
avoids allocating a new array instance).x
- the x-coordinate of the top-left pixel.y
- the y-coordinate of the top-left pixel.w
- the width of the region of pixels.h
- the height of the region of pixels.dArray
- an array to populate with the sample values and return as
the result (if null
, a new array will be allocated).public int getSample(int x, int y, int b)
x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.b
- the band (in the range 0
to
getNumBands() - 1
).public float getSampleFloat(int x, int y, int b)
x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.b
- the band (in the range 0
to
getNumBands() - 1
).getSample(int, int, int)
public double getSampleDouble(int x, int y, int b)
x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.b
- the band (in the range 0
to
getNumBands() - 1
).getSample(int, int, int)
public int[] getSamples(int x, int y, int w, int h, int b, int[] iArray)
iArray
is not null
, it will be
populated with the sample values and returned as the result of this
function (this avoids allocating a new array instance).x
- the x-coordinate of the top-left pixel.y
- the y-coordinate of the top-left pixel.w
- the width of the region of pixels.h
- the height of the region of pixels.b
- the band (in the range 0
to
getNumBands() - 1).iArray
- an array to populate with the sample values and return as
the result (if null
, a new array will be allocated).public float[] getSamples(int x, int y, int w, int h, int b, float[] fArray)
fArray
is not null
, it will be
populated with the sample values and returned as the result of this
function (this avoids allocating a new array instance).x
- the x-coordinate of the top-left pixel.y
- the y-coordinate of the top-left pixel.w
- the width of the region of pixels.h
- the height of the region of pixels.b
- the band (in the range 0
to
getNumBands() - 1).fArray
- an array to populate with the sample values and return as
the result (if null
, a new array will be allocated).public double[] getSamples(int x, int y, int w, int h, int b, double[] dArray)
dArray
is not null
, it will be
populated with the sample values and returned as the result of this
function (this avoids allocating a new array instance).x
- the x-coordinate of the top-left pixel.y
- the y-coordinate of the top-left pixel.w
- the width of the region of pixels.h
- the height of the region of pixels.b
- the band (in the range 0
to
getNumBands() - 1).dArray
- an array to populate with the sample values and return as
the result (if null
, a new array will be allocated).public String toString()
toString
in class Object
Object.getClass()
,
Object.hashCode()
,
Class.getName()
,
Integer.toHexString(int)