JSR-209 (Final Release)

java.awt.image
Class DataBuffer

java.lang.Object
  extended byjava.awt.image.DataBuffer
Direct Known Subclasses:
DataBufferInt

public abstract class DataBuffer
extends java.lang.Object

This class exists to wrap one or more data arrays. Each data array in the DataBuffer is referred to as a bank. The data type of a data buffer indicates the type of the data array(s). The data type may be TYPE_UNDEFINED or one of the types defined below. DataBuffers cannot be created directly. They can only be obtained from BufferedImages by querying their Rasters. If an application needs to manipulate pixels directly, it can get the int array holding the pixels via the DataBuffer which is guaranteed to be a DataBufferInt when the BufferedImage is TYPE_INT_ARGB_PRE.

Restrictions

Note that a BufferedImage obtained via the factory methods on GraphicsConfiguration or through the ImageIO API are not guaranteed to be of any particular type. If it is not TYPE_INT_ARGB_PRE, then the API implementation is free to use some other subclass of DataBuffer, which is opaque to the application. The pixel store for such a custom DataBuffer might not be a Java array (int or otherwise).


Field Summary
protected  int dataType
          The data type of this DataBuffer.
protected  int size
          Usable size of all banks.
static int TYPE_BYTE
          Tag for unsigned byte data.
static int TYPE_INT
          Tag for int data.
static int TYPE_UNDEFINED
          Tag for undefined data.
static int TYPE_USHORT
          Tag for unsigned short data.
 
Constructor Summary
protected DataBuffer(int dataType, int size)
          Constructs a DataBuffer containing one bank of the specified data type and size.
 
Method Summary
 int getDataType()
          Returns the data type of this DataBuffer.
 int getSize()
          Returns the size (in array elements) of the bank.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_BYTE

public static final int TYPE_BYTE
Tag for unsigned byte data.

See Also:
Constant Field Values

TYPE_USHORT

public static final int TYPE_USHORT
Tag for unsigned short data.

See Also:
Constant Field Values

TYPE_INT

public static final int TYPE_INT
Tag for int data.

See Also:
Constant Field Values

TYPE_UNDEFINED

public static final int TYPE_UNDEFINED
Tag for undefined data.

See Also:
Constant Field Values

dataType

protected int dataType
The data type of this DataBuffer.


size

protected int size
Usable size of all banks.

Constructor Detail

DataBuffer

protected DataBuffer(int dataType,
                     int size)
Constructs a DataBuffer containing one bank of the specified data type and size.

Parameters:
dataType - the data type of this DataBuffer
size - the size of the bank
Method Detail

getDataType

public int getDataType()
Returns the data type of this DataBuffer.

Returns:
the data type of this DataBuffer.

getSize

public int getSize()
Returns the size (in array elements) of the bank.

Returns:
the size of the bank.

JSR-209 (Final Release)

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.