All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class java.awt.image.Raster

java.lang.Object
    |
    +----java.awt.image.Raster

public class Raster
extends Object
This class represents a rectanglular array of pixels and provides methods for retrieving image data. It contains a DataBuffer object that holds a buffer of image data in some format, a SampleModel which describes the format is capable of storing and retrieving Samples from the DataBuffer, and a Rect that defines the coordinate space of the raster (upper left corner, width and height). The Raster's coordinate space is determined by a point and a rectangle. The Point is the origin of the base Raster (this raster's ancestor that has no parent.) The rectangle called the bounds determines the span over which this Raster can process pixel and sample requests. A point and a rectangle are needed so that sub rasters can use the same DataBuffer and SampleModel as their parent rasters. The point marks the origin of the SampleModel in the sub raster's coordinate space (possibly translated from the parent's coordinate space.) The rectangle defines the span of the sub raster. For base Rasters, the upper left corner of the bounds rectangle is equal to the origin. All constructors are protected. The correct way to create a Raster is to use one of the static create methods defined in this class.


Variable Index

 o baseRasterOriginX
The X offset of the base Raster from the global origin.
 o baseRasterOriginY
The Y offset of the base Raster from the global origin.
 o dataBuffer
DataBuffer that stores image data.
 o height
The height of the Raster.
 o minX
The X offset from the global origin.
 o minY
The Y offset from the global origin.
 o numBands
The number of bands in the raster.
 o numDataElements
The number of data elements per pixel.
 o parent
If non-null, the parent of this Raster.
 o sampleModel
SampleModel that describes how pixels are stored in the DataBuffer.
 o width
The width of the Raster.

Constructor Index

 o Raster(SampleModel, DataBuffer, Point)
Constructs a Raster with the given SampleModel and DataBuffer.
 o Raster(SampleModel, DataBuffer, Rectangle, Point, Raster)
Constructs a Raster with the given SampleModel, DataBuffer, and parent.
 o Raster(SampleModel, Point)
Constructs a Raster with the given SampleModel.

Method Index

 o createCompatibleWritableRaster()
Create a compatible WritableRaster the same size as this Raster with the same SampleModel and a new initialized DataBuffer.
 o createCompatibleWritableRaster(int, int)
Create a compatible WritableRaster with the specified size, a new SampleModel, and a new initialized DataBuffer.
 o createComponentRaster(int, int, int, int, int, int[], DataBuffer, Point)
Creates a Raster based on a ComponentSampleModel with the specified data type, width, height, scanline stride, pixel stride, band offsets, and data buffer.
 o createComponentRaster(int, int, int, int, int, int[], Point)
Creates a Raster based on a ComponentSampleModel with the specified data type, width, height, scanline stride, pixel stride, and band offsets.
 o createComponentRaster(int, int, int, int, Point)
Creates a Raster based on a ComponentSampleModel with the specified data type, width, height, and number of bands.
 o createPackedRaster(int, int, int, int, DataBuffer, Point)
Creates a Raster based on a SingleBandPackedSampleModel with the specified data type, width, height, bits per pixel, and data buffer.
 o createPackedRaster(int, int, int, int, int, Point)
Creates a Raster based on a packed SampleModel with the specified data type, width, height, number of bands, and bits per band.
 o createPackedRaster(int, int, int, int, int[], DataBuffer, Point)
Creates a Raster based on a MultiBandPackedSampleModel with the specified data type, width, height, scanline stride, band masks, and data buffer.
 o createPackedRaster(int, int, int, int[], Point)
Creates a Raster based on a MultiBandPackedSampleModel with the specified data type, width, height, and band masks.
 o createRaster(SampleModel, DataBuffer, Point)
Creates a Raster with the specified SampleModel
 o createSubRaster(int, int, int, int)
Returns a Raster which references this Raster's DataBuffer.
 o createSubRaster(int, int, int, int, int, int, int[])
Returns a translated SubRaster which references this Raster's DataBuffer.
 o createSubRaster(Rectangle)
Returns a Raster which references this Raster's DataBuffer
 o createWritableRaster(SampleModel, DataBuffer, Point)
Creates a WritableRaster with the specified SampleModel and DataBuffer
 o createWritableRaster(SampleModel, Point)
Creates a WritableRaster with the specified SampleModel
 o getBaseRasterOriginX()
Returns the X coord of the origin of the base Raster in this Raster's coordinate system.
 o getBaseRasterOriginY()
Returns the Y coord of the origin of the base Raster in this Raster's coordinate system.
 o getBaseSubRasterOffsetX()
 o getBaseSubRasterOffsetY()
 o getBounds()
Returns the bounds Rectangle of this Raster.
 o getDataBuffer()
Returns the DataBuffer associated with this Raster.
 o getHeight()
Returns the height in pixels of the Raster.
 o getMinX()
Returns the minimum X coordinate (in the Raster's coordinate system).
 o getMinY()
Returns the minimum Y coordinate (in the Raster's coordinate system).
 o getNumBands()
Returns the number of bands in this raster.
 o getNumDataElements()
Returns the number of data elements needed to store one pixel.
 o getParent()
Returns the parent Raster (if any) of this Raster
 o getPixel(int, int, double[])
Returns the samples in an array of double for the specified pixel
 o getPixel(int, int, float[])
Returns the samples in an array of Float for the specified pixel.
 o getPixel(int, int, int, int, double[])
Return a double array of pixels representing a region of pixels
 o getPixel(int, int, int, int, float[])
Return a float array of pixels representing a region of pixels
 o getPixel(int, int, int, int, int[])
Returns a integer array of pixels representing a region of pixels
 o getPixel(int, int, int[])
Returns the samples in an array of int for the specified pixel.
 o getPixelData(int, int, int, int, Object)
Returns the data elements containing the pixel data for the pixels in the specified region.
 o getPixelData(int, int, Object)
Returns the data elements containing the pixel at x,y in packed format.
 o getSample(int, int, int)
Returns the requested sample in a specified band for a pixel.
 o getSample(int, int, int, int, int, double[])
Return an array of ints representing a region of samples
 o getSample(int, int, int, int, int, float[])
Returns an array of floats representing a region of samples.
 o getSample(int, int, int, int, int, int[])
Returns an array of ints representing a region of samples.
 o getSampleDouble(int, int, int)
Returns the requested sample in a specified band for a pixel.
 o getSampleFloat(int, int, int)
Returns the requested sample in a specified band for a pixel.
 o getSampleModel()
Returns the SampleModel that describes that layout of the image data.
 o getTransferType()
 o getWidth()
Returns the width in pixels of the Raster.

Variables

 o sampleModel
protected SampleModel sampleModel
SampleModel that describes how pixels are stored in the DataBuffer.

 o dataBuffer
protected DataBuffer dataBuffer
DataBuffer that stores image data.

 o width
protected int width
The width of the Raster.

 o height
protected int height
The height of the Raster.

 o minX
protected int minX
The X offset from the global origin.

 o minY
protected int minY
The Y offset from the global origin.

 o baseRasterOriginX
protected int baseRasterOriginX
The X offset of the base Raster from the global origin.

 o baseRasterOriginY
protected int baseRasterOriginY
The Y offset of the base Raster from the global origin.

 o numBands
protected int numBands
The number of bands in the raster.

 o numDataElements
protected int numDataElements
The number of data elements per pixel.

 o parent
protected Raster parent
If non-null, the parent of this Raster.

Constructors

 o Raster
protected Raster(SampleModel sampleModel,
                 Point origin)
Constructs a Raster 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.

Parameters:
sampleModel - The SampleModel that specifies the layout.
origin - The Point that specified the origin.
 o Raster
protected Raster(SampleModel sampleModel,
                 DataBuffer dataBuffer,
                 Point origin)
Constructs a Raster 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 compatible with SampleModel.

Parameters:
sampleModel - The SampleModel that specifies the layout.
dataBuffer - The DataBufferShort that contains the image data.
origin - The Point that specifies the origin.
 o Raster
protected Raster(SampleModel sampleModel,
                 DataBuffer dataBuffer,
                 Rectangle aRegion,
                 Point baseOrigin,
                 Raster parent)
Constructs a Raster with the given SampleModel, DataBuffer, and parent. When translated into the base Raster's coordinate system, aRegion must be contained by the base Raster. Origin is the coodinate 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.

Parameters:
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.

Methods

 o createComponentRaster
public static WritableRaster createComponentRaster(int dataType,
                                                   int w,
                                                   int h,
                                                   int n,
                                                   Point location)
Creates a Raster based on a ComponentSampleModel with the specified data type, width, height, and number of bands.

 o createComponentRaster
public static WritableRaster createComponentRaster(int dataType,
                                                   int w,
                                                   int h,
                                                   int scanlineStride,
                                                   int pixelStride,
                                                   int[] bandOffsets,
                                                   Point location)
Creates a Raster based on a ComponentSampleModel with the specified data type, width, height, scanline stride, pixel stride, and band offsets.

 o createPackedRaster
public static WritableRaster createPackedRaster(int dataType,
                                                int w,
                                                int h,
                                                int[] bandMasks,
                                                Point location)
Creates a Raster based on a MultiBandPackedSampleModel with the specified data type, width, height, and band masks.

 o createPackedRaster
public static WritableRaster createPackedRaster(int dataType,
                                                int w,
                                                int h,
                                                int n,
                                                int bitsPerBand,
                                                Point location)
Creates a Raster based on a packed SampleModel with the specified data type, width, height, number of bands, and bits per band. If the number of bands is one, the SampleModel will be a SingleBandPackedSampleModel. If the number of bands is more than one, the SampleModel will be a MultiBandPackedSampleModel, with each band having bitsPerBand bits. In either case, the requirements on dataType and bitsPerBand imposed by the corresponding SampleModel must be met.

 o createComponentRaster
public static WritableRaster createComponentRaster(int dataType,
                                                   int w,
                                                   int h,
                                                   int scanlineStride,
                                                   int pixelStride,
                                                   int[] bandOffsets,
                                                   DataBuffer dataBuffer,
                                                   Point location)
Creates a Raster based on a ComponentSampleModel with the specified data type, width, height, scanline stride, pixel stride, band offsets, and data buffer.

 o createPackedRaster
public static WritableRaster createPackedRaster(int dataType,
                                                int w,
                                                int h,
                                                int scanlineStride,
                                                int[] bandMasks,
                                                DataBuffer dataBuffer,
                                                Point location)
Creates a Raster based on a MultiBandPackedSampleModel with the specified data type, width, height, scanline stride, band masks, and data buffer.

 o createPackedRaster
public static WritableRaster createPackedRaster(int dataType,
                                                int w,
                                                int h,
                                                int bitsPerPixel,
                                                DataBuffer dataBuffer,
                                                Point location)
Creates a Raster based on a SingleBandPackedSampleModel with the specified data type, width, height, bits per pixel, and data buffer.

 o createRaster
public static Raster createRaster(SampleModel sm,
                                  DataBuffer dataBuffer,
                                  Point location)
Creates a Raster with the specified SampleModel

 o createWritableRaster
public static WritableRaster createWritableRaster(SampleModel sm,
                                                  Point location)
Creates a WritableRaster with the specified SampleModel

 o createWritableRaster
public static WritableRaster createWritableRaster(SampleModel sm,
                                                  DataBuffer db,
                                                  Point location)
Creates a WritableRaster with the specified SampleModel and DataBuffer

 o getParent
public Raster getParent()
Returns the parent Raster (if any) of this Raster

 o getBaseRasterOriginX
public final int getBaseRasterOriginX()
Returns the X coord of the origin of the base Raster in this Raster's coordinate system.

 o getBaseRasterOriginY
public final int getBaseRasterOriginY()
Returns the Y coord of the origin of the base Raster in this Raster's coordinate system.

 o getBaseSubRasterOffsetX
public final int getBaseSubRasterOffsetX()
 o getBaseSubRasterOffsetY
public final int getBaseSubRasterOffsetY()
 o createCompatibleWritableRaster
public WritableRaster createCompatibleWritableRaster()
Create a compatible WritableRaster the same size as this Raster with the same SampleModel and a new initialized DataBuffer.

 o createCompatibleWritableRaster
public WritableRaster createCompatibleWritableRaster(int w,
                                                     int h)
Create a compatible WritableRaster with the specified size, a new SampleModel, and a new initialized DataBuffer.

 o createSubRaster
public Raster createSubRaster(Rectangle rect)
Returns a Raster which references this Raster's DataBuffer

Parameters:
rect - is a rectangle in this Raster's coordinate space. An error is thrown if rect is not fully contained by this Raster.
 o createSubRaster
public Raster createSubRaster(int x,
                              int y,
                              int width,
                              int height)
Returns a Raster which references this Raster's DataBuffer. x,y, width and height form a Rectangle in this Raster's coordinate space. An error is thrown if this rectangle is not fully contained by this Raster.

Parameters:
x - The X coordinate of the upper left hand corner.
y - The Y coordinate of the upper left hand corner.
width - Width of the region starting at (x,y).
height - Height of the region starting at (x,y).
 o createSubRaster
public Raster createSubRaster(int x,
                              int y,
                              int width,
                              int height,
                              int x0,
                              int y0,
                              int[] bandList)
Returns a translated SubRaster which references this Raster's DataBuffer. x,y, width and height form a Rectangle in this Raster's coordinate space. The new Raster's coordinate system has an upper left corner of x0, y0. An error is thrown if rectangle is not fully contained by this Raster.

Parameters:
x - X of the upper left corner in this Raster's coordinates.
y - Y of the upper left corner in this Raster's coordinates.
width - Width of the region starting at (x,y).
height - Height of the region starting at (x,y).
x0 - X of the upper left corner of returned Raster.
y0 - Y of the upper left corner of returned Raster.
bandList - Array of band indices.
 o getBounds
public Rectangle getBounds()
Returns the bounds Rectangle of this Raster. This function returns the same information as getMinX/MinY/Width/Height.

 o getWidth
public final int getWidth()
Returns the width in pixels of the Raster.

 o getHeight
public final int getHeight()
Returns the height in pixels of the Raster.

 o getMinX
public final int getMinX()
Returns the minimum X coordinate (in the Raster's coordinate system).

 o getMinY
public final int getMinY()
Returns the minimum Y coordinate (in the Raster's coordinate system).

 o getNumBands
public final int getNumBands()
Returns the number of bands in this raster.

 o getNumDataElements
public final int getNumDataElements()
Returns the number of data elements needed to store one pixel.

 o getTransferType
public final int getTransferType()
 o getPixelData
public Object getPixelData(int x,
                           int y,
                           Object obj)
Returns the data elements containing the pixel at x,y in packed format. There will be no explicit bounds checking on the parameters. An ArrayOutOfBounds exception will be thrown at runtime if data outside of the array is accessed. A ClassCastException will be thrown if the input object is non null and references anything other than an array of transferType.

Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
outData - 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:
An object reference to an array of type defined by getTransferType() with the request pixel data.
 o getPixelData
public Object getPixelData(int x,
                           int y,
                           int w,
                           int h,
                           Object obj)
Returns the data elements containing the pixel data for the pixels in the specified region. There will be no explicit bounds checking on the parameters. An ArrayOutOfBounds exception will be thrown at runtime if data outside of the array is accessed. A ClassCastException will be thrown if the input object is non null and references anything other than an array of transferType.

Parameters:
x - The X coordinate of the upper left pixel location.
y - The Y coordinate of the upper left pixel location.
width - Width of the pixel rectangle.
height - 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:
An object reference to an array of type defined by getTransferType() with the request pixel data.
 o getPixel
public int[] getPixel(int x,
                      int y,
                      int[] iarray)
Returns the samples in an array of int for the specified pixel.

Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
iarray - An optionally preallocated int array.
 o getPixel
public float[] getPixel(int x,
                        int y,
                        float[] farray)
Returns the samples in an array of Float for the specified pixel.

Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
farray - An optionally preallocated float array.
 o getPixel
public double[] getPixel(int x,
                         int y,
                         double[] darray)
Returns the samples in an array of double for the specified pixel

Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
darray - An optionally preallocated double array.
 o getPixel
public int[] getPixel(int x,
                      int y,
                      int w,
                      int h,
                      int[] iarray)
Returns a integer array of pixels representing a region of pixels

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 - An optionally pre-allocated int array.
 o getPixel
public float[] getPixel(int x,
                        int y,
                        int w,
                        int h,
                        float[] farray)
Return a float array of pixels representing a region of pixels

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.
farray - An optionally pre-allocated float array.
 o getPixel
public double[] getPixel(int x,
                         int y,
                         int w,
                         int h,
                         double[] darray)
Return a double array of pixels representing a region of pixels

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.
darray - An optionally pre-allocated double array.
 o getSample
public int getSample(int x,
                     int y,
                     int b)
Returns the requested sample in a specified band for a pixel.

Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
b - The band to return.
 o getSampleFloat
public float getSampleFloat(int x,
                            int y,
                            int b)
Returns the requested sample in a specified band for a pixel.

Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
b - The band to return.
 o getSampleDouble
public double getSampleDouble(int x,
                              int y,
                              int b)
Returns the requested sample in a specified band for a pixel.

Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
b - The band to return.
 o getSample
public int[] getSample(int x,
                       int y,
                       int w,
                       int h,
                       int b,
                       int[] iarray)
Returns an array of ints representing a region of samples.

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 return.
iarray - An optionally pre-allocated int array.
 o getSample
public float[] getSample(int x,
                         int y,
                         int w,
                         int h,
                         int b,
                         float[] farray)
Returns an array of floats representing a region of samples.

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 return.
farray - An optionally pre-allocated float array.
 o getSample
public double[] getSample(int x,
                          int y,
                          int w,
                          int h,
                          int b,
                          double[] darray)
Return an array of ints representing a region of samples

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 return.
darray - An optionally pre-allocated double array.
 o getDataBuffer
public DataBuffer getDataBuffer()
Returns the DataBuffer associated with this Raster.

 o getSampleModel
public SampleModel getSampleModel()
Returns the SampleModel that describes that layout of the image data.


All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Submit a bug or feature