java.awt.image

Class DataBuffer

Known Direct Subclasses:
DataBufferByte, DataBufferDouble, DataBufferFloat, DataBufferInt, DataBufferShort, DataBufferUShort

public abstract class DataBuffer
extends Object

This class exists to wrap one or more data arrays. Each data array in the DataBuffer is referred to as a bank. Accessor methods for getting and setting elements of the DataBuffer's banks exist with and without a bank specifier. The methods without a bank specifier use the default 0th bank. The DataBuffer can optionally take an offset per bank, so that data in an existing array can be used even if the interesting data doesn't start at array location zero. Getting or setting the 0th element of a bank, uses the (0+offset)th element of the array. The size field specifies how much of the data array is available for use. Size + offset for a given bank should never be greater than the length of the associated data array. The data type of a data buffer indicates the type of the data array(s) and may also indicate additional semantics, e.g. storing unsigned 8-bit data in elements of a byte array. The data type may be TYPE_UNDEFINED or one of the types defined below. Other types may be added in the future. Generally, an object of class DataBuffer will be cast down to one of its data type specific subclasses to access data type specific methods for improved performance. Currently, the Java 2D(tm) API image classes use TYPE_BYTE, TYPE_USHORT, TYPE_INT, TYPE_SHORT, TYPE_FLOAT, and TYPE_DOUBLE DataBuffers to store image data.
See Also:
Raster, SampleModel

Field Summary

static int
TYPE_BYTE
Tag for unsigned byte data.
static int
TYPE_DOUBLE
Tag for double data.
static int
TYPE_FLOAT
Tag for float data.
static int
TYPE_INT
Tag for int data.
static int
TYPE_SHORT
Tag for signed short data.
static int
TYPE_UNDEFINED
Tag for undefined data.
static int
TYPE_USHORT
Tag for unsigned short data.
protected int
banks
The number of banks in this DataBuffer.
protected int
dataType
The data type of this DataBuffer.
protected int
offset
Offset into default (first) bank from which to get the first element.
protected int[]
offsets
Offsets into all banks.
protected int
size
Usable size of all banks.

Constructor Summary

DataBuffer(int dataType, int size)
Constructs a DataBuffer containing one bank of the specified data type and size.
DataBuffer(int dataType, int size, int numBanks)
Constructs a DataBuffer containing the specified number of banks.
DataBuffer(int dataType, int size, int numBanks, int offset)
Constructs a DataBuffer that contains the specified number of banks.
DataBuffer(int dataType, int size, int numBanks, offsets[] )
Constructs a DataBuffer which contains the specified number of banks.

Method Summary

int
getDataType()
Returns the data type of this DataBuffer.
static int
getDataTypeSize(int type)
Returns the size (in bits) of the data type, given a datatype tag.
int
getElem(int i)
Returns the requested data array element from the first (default) bank as an integer.
abstract int
getElem(int bank, int i)
Returns the requested data array element from the specified bank as an integer.
double
getElemDouble(int i)
Returns the requested data array element from the first (default) bank as a double.
double
getElemDouble(int bank, int i)
Returns the requested data array element from the specified bank as a double.
float
getElemFloat(int i)
Returns the requested data array element from the first (default) bank as a float.
float
getElemFloat(int bank, int i)
Returns the requested data array element from the specified bank as a float.
int
getNumBanks()
Returns the number of banks in this DataBuffer.
int
getOffset()
Returns the offset of the default bank in array elements.
int[]
getOffsets()
Returns the offsets (in array elements) of all the banks.
int
getSize()
Returns the size (in array elements) of all banks.
void
setElem(int i, int val)
Sets the requested data array element in the first (default) bank from the given integer.
abstract void
setElem(int bank, int i, int val)
Sets the requested data array element in the specified bank from the given integer.
void
setElemDouble(int i, double val)
Sets the requested data array element in the first (default) bank from the given double.
void
setElemDouble(int bank, int i, double val)
Sets the requested data array element in the specified bank from the given double.
void
setElemFloat(int i, float val)
Sets the requested data array element in the first (default) bank from the given float.
void
setElemFloat(int bank, int i, float val)
Sets the requested data array element in the specified bank from the given float.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

TYPE_BYTE

public static final int TYPE_BYTE
Tag for unsigned byte data.
Field Value:
0
Usages and Demos :

View More Examples of DataBuffer.TYPE_BYTE
   1:                             ComponentColorModel.TRANSLUCENT,
   2:                             DataBuffer.TYPE_BYTE);
   3: 
   4:         ...
   5:                                                ComponentColorModel.OPAQUE,
   6:                                                DataBuffer.TYPE_BYTE);
   7: 
   8:         ...
   9:         if (bufferedImage.getColorModel().hasAlpha()) {
  10:             raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,texWidth,texHeight,4,null);
  11:             texImage = new BufferedImage(glAlphaColorModel,raster,false,new Hashtable());

View Full Code Here
   1:                    Transparency.OPAQUE, 
   2:                    DataBuffer.TYPE_BYTE),
   3:               new PixelInterleavedSampleModel
   4:         ...
   5:                   (DataBuffer.TYPE_BYTE, 
   6:                    src.getSampleModel().getWidth(),
   7:                    src.getSampleModel().getHeight(),
   8:                    1, src.getSampleModel().getWidth(),

View Full Code Here
   1:         switch (dt) {
   2:         case DataBuffer.TYPE_BYTE:   bits=8;  break;
   3:         case DataBuffer.TYPE_SHORT:  bits=16; break;
   4:         case DataBuffer.TYPE_USHORT: bits=16; break;
   5:         case DataBuffer.TYPE_INT:    bits=32; break;

View Full Code Here
   1:         {
   2:             case DataBuffer.TYPE_BYTE:
   3:                 return new DataBufferByte(size, numBanks);
   4:         ...
   5:         {
   6:             case DataBuffer.TYPE_BYTE:
   7:                 return new DataBufferByte((byte[])data, size);
   8:         ...
   9:         {
  10:             return DataBuffer.TYPE_BYTE;
  11:         }

View Full Code Here
   1:       {
   2:         t = DataBuffer.TYPE_BYTE;
   3:         db = getByteBuffer();
   4:         ...
   5:       case 8:
   6:         sm = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 
   7:                       width, height, 1, width,
   8:         ...
   9:       default:
  10:         sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE, 
  11:                          width, height, depth);

View Full Code Here

TYPE_DOUBLE

public static final int TYPE_DOUBLE
Tag for double data. Placeholder for future use.
Field Value:
5
Usages and Demos :

View More Examples of DataBuffer.TYPE_DOUBLE
   1:                 return new DataBufferFloat(size, numBanks);
   2:             case DataBuffer.TYPE_DOUBLE:
   3:                 return new DataBufferDouble(size, numBanks);
   4:         ...
   5:                 return new DataBufferFloat((float[])data, size);
   6:             case DataBuffer.TYPE_DOUBLE:
   7:                 return new DataBufferDouble((double[])data, size);
   8:             default:
   9:                 throw new UnsupportedOperationException();

View Full Code Here
   1:             break;
   2:         case DataBuffer.TYPE_DOUBLE:
   3:             array = DataBufferUtils.getBankDataDouble(db);
   4:         ...
   5:             break;
   6:         case DataBuffer.TYPE_DOUBLE:
   7:             bytesPerElement = 8;
   8:         ...
   9:                     break;
  10:                 case DataBuffer.TYPE_DOUBLE: {
  11:                     double[][] bankData = (double[][]) array;

View Full Code Here
   1:             break;
   2:         case DataBuffer.TYPE_DOUBLE:
   3:             array = DataBufferUtils.getBankDataDouble(db);
   4:         ...
   5:             break;
   6:         case DataBuffer.TYPE_DOUBLE:
   7:             bytesPerElement = 8;
   8:         ...
   9:                     break;
  10:                 case DataBuffer.TYPE_DOUBLE: {
  11:                     double[][] bankData = (double[][]) array;

View Full Code Here
   1:                 case DataBuffer.TYPE_FLOAT:   type=Float  .class; digits=2; break;
   2:                 case DataBuffer.TYPE_DOUBLE:  type=Double .class; digits=3; break;
   3:                 default:                      type=Number .class;           break;
   4:         ...
   5:             case DataBuffer.TYPE_FLOAT:   return new Float  (raster.getSampleFloat (x,y,band));
   6:             case DataBuffer.TYPE_DOUBLE:  return new Double (raster.getSampleDouble(x,y,band));
   7:         }
   8:     }

View Full Code Here
   1:             case DataBuffer.TYPE_FLOAT:
   2:             case DataBuffer.TYPE_DOUBLE: {
   3:                 categories = new Category[2];
   4:         ...
   5:             case DataBuffer.TYPE_FLOAT:  classe =   Float.class; break;
   6:             case DataBuffer.TYPE_DOUBLE: classe =  Double.class; break;
   7:             default: {
   8:                 for (int b=0; b<numBands; b++) {
   9:                     classe = ClassChanger.getWidestClass(classe,

View Full Code Here

TYPE_FLOAT

public static final int TYPE_FLOAT
Tag for float data. Placeholder for future use.
Field Value:
4
Usages and Demos :

View More Examples of DataBuffer.TYPE_FLOAT
   1:                 return new DataBufferInt(size, numBanks);
   2:             case DataBuffer.TYPE_FLOAT:
   3:                 return new DataBufferFloat(size, numBanks);
   4:         ...
   5:                 return new DataBufferInt((int[])data, size);
   6:             case DataBuffer.TYPE_FLOAT:
   7:                 return new DataBufferFloat((float[])data, size);
   8:             case DataBuffer.TYPE_DOUBLE:
   9:                 return new DataBufferDouble((double[])data, size);

View Full Code Here
   1:             break;
   2:         case DataBuffer.TYPE_FLOAT:
   3:             array = DataBufferUtils.getBankDataFloat(db);
   4:         ...
   5:         case DataBuffer.TYPE_INT:
   6:         case DataBuffer.TYPE_FLOAT:
   7:             bytesPerElement = 4;
   8:         ...
   9:                     break;
  10:                 case DataBuffer.TYPE_FLOAT: {
  11:                     float[][] bankData = (float[][]) array;

View Full Code Here
   1:             break;
   2:         case DataBuffer.TYPE_FLOAT:
   3:             array = DataBufferUtils.getBankDataFloat(db);
   4:         ...
   5:         case DataBuffer.TYPE_INT:
   6:         case DataBuffer.TYPE_FLOAT:
   7:             bytesPerElement = 4;
   8:         ...
   9:                     break;
  10:                 case DataBuffer.TYPE_FLOAT: {
  11:                     float[][] bankData = (float[][]) array;

View Full Code Here

TYPE_INT

public static final int TYPE_INT
Tag for int data.
Field Value:
3
Usages and Demos :

View More Examples of DataBuffer.TYPE_INT
   1:         case DataBuffer.TYPE_USHORT: bits=16; break;
   2:         case DataBuffer.TYPE_INT:    bits=32; break;
   3:         default:
   4:             throw new IllegalArgumentException
   5:                 ("Unsupported DataBuffer type: " + dt);

View Full Code Here
   1:                 return new DataBufferUShort(size, numBanks);
   2:             case DataBuffer.TYPE_INT:
   3:                 return new DataBufferInt(size, numBanks);
   4:         ...
   5:                 return new DataBufferUShort((short[])data, size);
   6:             case DataBuffer.TYPE_INT:
   7:                 return new DataBufferInt((int[])data, size);
   8:         ...
   9:         {
  10:             return DataBuffer.TYPE_INT;
  11:         }

View Full Code Here
   1:                                         masks[2], masks[3],
   2:                                         true, DataBuffer.TYPE_INT);
   3:         }
   4:         ...
   5:                                        Transparency.TRANSLUCENT,
   6:                                        DataBuffer.TYPE_INT);
   7:         
   8:     }

View Full Code Here
   1:                 case DataBuffer.TYPE_BYTE:   pixel=new byte [numBands]; break;
   2:                 case DataBuffer.TYPE_INT:    pixel=new int  [numBands]; break;
   3:                 default: throw new UnsupportedOperationException(unsupported());
   4:         ...
   5:             }
   6:             case DataBuffer.TYPE_INT: {
   7:                 final int[] array = (int[]) pixel;
   8:         ...
   9:             case DataBuffer.TYPE_BYTE:   i=((byte [])pixel)[visibleBand] & 0xff;   break;
  10:             case DataBuffer.TYPE_INT:    i=((int  [])pixel)[visibleBand];          break;
  11:             default: throw new UnsupportedOperationException(unsupported());

View Full Code Here
   1:                 case DataBuffer.TYPE_BYTE:   pixel=new byte [numBands]; break;
   2:                 case DataBuffer.TYPE_INT:    pixel=new int  [numBands]; break;
   3:                 default: throw new UnsupportedOperationException(unsupported());
   4:         ...
   5:             }
   6:             case DataBuffer.TYPE_INT: {
   7:                 final int[] array = (int[]) pixel;
   8:         ...
   9:             case DataBuffer.TYPE_BYTE:   i=((byte [])pixel)[visibleBand] & 0xff;   break;
  10:             case DataBuffer.TYPE_INT:    i=((int  [])pixel)[visibleBand];          break;
  11:             default: throw new UnsupportedOperationException(unsupported());

View Full Code Here

TYPE_SHORT

public static final int TYPE_SHORT
Tag for signed short data. Placeholder for future use.
Field Value:
2
Usages and Demos :

View More Examples of DataBuffer.TYPE_SHORT
   1:         case DataBuffer.TYPE_BYTE:   bits=8;  break;
   2:         case DataBuffer.TYPE_SHORT:  bits=16; break;
   3:         case DataBuffer.TYPE_USHORT: bits=16; break;
   4:         case DataBuffer.TYPE_INT:    bits=32; break;
   5:         default:

View Full Code Here
   1:                 return new DataBufferByte(size, numBanks);
   2:             case DataBuffer.TYPE_SHORT:
   3:                 return new DataBufferShort(size, numBanks);
   4:         ...
   5:                 return new DataBufferByte((byte[])data, size);
   6:             case DataBuffer.TYPE_SHORT:
   7:                 return new DataBufferShort((short[])data, size);
   8:             case DataBuffer.TYPE_USHORT:
   9:                 return new DataBufferUShort((short[])data, size);

View Full Code Here
   1:             break;
   2:         case DataBuffer.TYPE_SHORT:
   3:             if (byteOrder == ByteOrder.LITTLE_ENDIAN)
   4:                 for (int i = 0; i < h; ++i)
   5:                     writeShortLE(((DataBufferShort) buffer).getData(), i

View Full Code Here
   1:                 }
   2:                 case DataBuffer.TYPE_SHORT:
   3:                 case DataBuffer.TYPE_USHORT: {
   4:         ...
   5:                     length = 0x10000;
   6:                     offset = (sourceType==DataBuffer.TYPE_SHORT) ? Short.MIN_VALUE : 0;
   7:                     break;
   8:         ...
   9: 
  10:                 case DataBuffer.TYPE_SHORT:
  11:                 case DataBuffer.TYPE_USHORT: {

View Full Code Here
   1:                 }
   2:                 case DataBuffer.TYPE_SHORT:
   3:                 case DataBuffer.TYPE_USHORT: {
   4:         ...
   5:                     length = 0x10000;
   6:                     offset = (sourceType==DataBuffer.TYPE_SHORT) ? Short.MIN_VALUE : 0;
   7:                     break;
   8:         ...
   9: 
  10:                 case DataBuffer.TYPE_SHORT:
  11:                 case DataBuffer.TYPE_USHORT: {

View Full Code Here

TYPE_UNDEFINED

public static final int TYPE_UNDEFINED
Tag for undefined data.
Field Value:
32
Usages and Demos :

View More Examples of DataBuffer.TYPE_UNDEFINED
   1:         {
   2:             return DataBuffer.TYPE_UNDEFINED;
   3:         }
   4:     }
   5: }

View Full Code Here
   1:     
   2:     private int dataType = DataBuffer.TYPE_UNDEFINED;
   3:     
   4:         ...
   5:     private int targetDataType = DataBuffer.TYPE_UNDEFINED;
   6:     
   7:         ...
   8:         if ((dataType<DataBuffer.TYPE_BYTE || dataType>DataBuffer.TYPE_DOUBLE) &&
   9:              dataType!=DataBuffer.TYPE_UNDEFINED)
  10:         {

View Full Code Here
   1:     
   2:     private int dataType = DataBuffer.TYPE_UNDEFINED;
   3:     
   4:         ...
   5:     private int targetDataType = DataBuffer.TYPE_UNDEFINED;
   6:     
   7:         ...
   8:         if ((dataType<DataBuffer.TYPE_BYTE || dataType>DataBuffer.TYPE_DOUBLE) &&
   9:              dataType!=DataBuffer.TYPE_UNDEFINED)
  10:         {

View Full Code Here
   1:         }
   2:         return DataBuffer.TYPE_UNDEFINED;
   3:     }
   4: 
   5:     public static int getSize(final SampleDimensionType type) {

View Full Code Here

TYPE_USHORT

public static final int TYPE_USHORT
Tag for unsigned short data.
Field Value:
1
Usages and Demos :

View More Examples of DataBuffer.TYPE_USHORT
   1:         case DataBuffer.TYPE_SHORT:  bits=16; break;
   2:         case DataBuffer.TYPE_USHORT: bits=16; break;
   3:         case DataBuffer.TYPE_INT:    bits=32; break;
   4:         default:
   5:             throw new IllegalArgumentException

View Full Code Here
   1:                 return new DataBufferShort(size, numBanks);
   2:             case DataBuffer.TYPE_USHORT:
   3:                 return new DataBufferUShort(size, numBanks);
   4:         ...
   5:                 return new DataBufferShort((short[])data, size);
   6:             case DataBuffer.TYPE_USHORT:
   7:                 return new DataBufferUShort((short[])data, size);
   8:         ...
   9:         {
  10:             return DataBuffer.TYPE_USHORT;
  11:         }

View Full Code Here
   1:             break;
   2:         case DataBuffer.TYPE_USHORT:
   3:             if (byteOrder == ByteOrder.LITTLE_ENDIAN)
   4:                 for (int i = 0; i < h; ++i)
   5:                     writeShortLE(((DataBufferUShort) buffer).getData(), i

View Full Code Here
   1:             switch (transferType) {
   2:                 case DataBuffer.TYPE_USHORT: pixel=new short[numBands]; break;
   3:                 case DataBuffer.TYPE_BYTE:   pixel=new byte [numBands]; break;
   4:         ...
   5:         switch (transferType) {
   6:             case DataBuffer.TYPE_USHORT: {
   7:                 final short[] array = (short[]) pixel;
   8:         ...
   9:         switch (transferType) {
  10:             case DataBuffer.TYPE_USHORT: i=((short[])pixel)[visibleBand] & 0xffff; break;
  11:             case DataBuffer.TYPE_BYTE:   i=((byte [])pixel)[visibleBand] & 0xff;   break;

View Full Code Here
   1:             switch (transferType) {
   2:                 case DataBuffer.TYPE_USHORT: pixel=new short[numBands]; break;
   3:                 case DataBuffer.TYPE_BYTE:   pixel=new byte [numBands]; break;
   4:         ...
   5:         switch (transferType) {
   6:             case DataBuffer.TYPE_USHORT: {
   7:                 final short[] array = (short[]) pixel;
   8:         ...
   9:         switch (transferType) {
  10:             case DataBuffer.TYPE_USHORT: i=((short[])pixel)[visibleBand] & 0xffff; break;
  11:             case DataBuffer.TYPE_BYTE:   i=((byte [])pixel)[visibleBand] & 0xff;   break;

View Full Code Here

banks

protected int banks
The number of banks in this DataBuffer.

dataType

protected int dataType
The data type of this DataBuffer.

offset

protected int offset
Offset into default (first) bank from which to get the first element.

offsets

protected int[] offsets
Offsets into all banks.

size

protected int size
Usable size of all banks.

Constructor Details

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 banks

DataBuffer

protected DataBuffer(int dataType,
                     int size,
                     int numBanks)
Constructs a DataBuffer containing the specified number of banks. Each bank has the specified size and an offset of 0.
Parameters:
dataType - the data type of this DataBuffer
size - the size of the banks
numBanks - the number of banks in this DataBuffer

DataBuffer

protected DataBuffer(int dataType,
                     int size,
                     int numBanks,
                     int offset)
Constructs a DataBuffer that contains the specified number of banks. Each bank has the specified datatype, size and offset.
Parameters:
dataType - the data type of this DataBuffer
size - the size of the banks
numBanks - the number of banks in this DataBuffer
offset - the offset for each bank

DataBuffer

protected DataBuffer(int dataType,
                     int size,
                     int numBanks,
                     offsets[] )
Constructs a DataBuffer which contains the specified number of banks. Each bank has the specified datatype and size. The offset for each bank is specified by its respective entry in the offsets array.
Parameters:
dataType - the data type of this DataBuffer
size - the size of the banks
numBanks - the number of banks in this DataBuffer
Throws:
ArrayIndexOutOfBoundsException - if numBanks does not equal the length of offsets

Method Details

getDataType

public int getDataType()
Returns the data type of this DataBuffer.
Returns:
the data type of this DataBuffer.
Usages and Demos :

View More Examples of getDataType()
   1: import java.awt.image.ComponentSampleModel;
   2: import java.awt.image.DataBuffer;
   3: import java.awt.image.DataBufferByte;
   4:         ...
   5:             ByteOrder byteOrder) throws IOException {
   6:         DataBuffer buffer = raster.getDataBuffer();
   7:         final int stride = ((ComponentSampleModel) raster.getSampleModel())
   8:         ...
   9:         final int wb = w * b;
  10:         switch (buffer.getDataType()) {
  11:         ...
  12:         case DataBuffer.TYPE_BYTE:

View Full Code Here
   1: import java.awt.image.ComponentSampleModel;
   2: import java.awt.image.DataBuffer;
   3: import java.awt.image.DataBufferByte;
   4:         ...
   5: 
   6:     private static Object getBankReference(DataBuffer db) {
   7:         Object array = null;
   8:         ...
   9: 
  10:         switch (db.getDataType()) {
  11:         ...
  12:         case DataBuffer.TYPE_BYTE:

View Full Code Here
   1: import java.awt.image.ComponentSampleModel;
   2: import java.awt.image.DataBuffer;
   3: import java.awt.image.DataBufferByte;
   4:         ...
   5: 
   6:     private static Object getBankReference(DataBuffer db) {
   7:         Object array = null;
   8:         ...
   9: 
  10:         switch (db.getDataType()) {
  11:         ...
  12:         case DataBuffer.TYPE_BYTE:

View Full Code Here
   1: import java.awt.image.ComponentColorModel;
   2: import java.awt.image.DataBuffer;
   3: import java.awt.image.DataBufferByte;
   4:         ...
   5:         case 8:
   6:             this.dataType = DataBuffer.TYPE_BYTE;
   7:             break;
   8:         ...
   9:         case 16:
  10:             this.dataType = pixelRepresentation == 0 || !supportSigned ? DataBuffer.TYPE_USHORT
  11:                     : DataBuffer.TYPE_SHORT;
  12:         ...
  13:                 default:
  14:                     throw new RuntimeException("dataType:" + db.getDataType());

View Full Code Here
   1: 
   2:     DataBuffer dataB = raster.getDataBuffer();
   3:     attachData(ximg, dataB, 0);
   4:         ...
   5:       Buffers.smallestAppropriateTransferType(bitsPerPixel);
   6:     int bitsPerDataElement = DataBuffer.getDataTypeSize(dataType);
   7:     int scanlineStride = ximage.getBytesPerLine()*8/bitsPerDataElement;
   8:         ...
   9: 
  10:   static void attachData(XImage ximage, DataBuffer dataB, int offset)
  11:   {
  12:         ...
  13:     offset += dataB.getOffset();
  14:     switch (dataB.getDataType())

View Full Code Here

getDataTypeSize

public static int getDataTypeSize(int type)
Returns the size (in bits) of the data type, given a datatype tag.
Parameters:
type - the value of one of the defined datatype tags
Returns:
the size of the data type
Throws:
IllegalArgumentException - if type is less than zero or greater than TYPE_DOUBLE
Usages and Demos :

View More Examples of getDataTypeSize(int type)
   1: import java.awt.image.ComponentSampleModel;
   2: import java.awt.image.DataBuffer;
   3: import java.awt.image.MultiPixelPackedSampleModel;
   4:         ...
   5:     
   6:     private int dataType = DataBuffer.TYPE_UNDEFINED;
   7:     
   8:         ...
   9:     private int targetDataType = DataBuffer.TYPE_UNDEFINED;
  10:     
  11:         ...
  12:                 final MultiPixelPackedSampleModel cast = (MultiPixelPackedSampleModel) model;
  13:                 final int numberOfBits   = DataBuffer.getDataTypeSize(dataType);

View Full Code Here
   1: import java.awt.color.ColorSpace;
   2: import java.awt.image.DataBuffer;
   3: import java.awt.image.ColorModel;
   4:         ...
   5:     
   6:     private int dataType = DataBuffer.TYPE_UNDEFINED;
   7:     
   8:         ...
   9:     private int targetDataType = DataBuffer.TYPE_UNDEFINED;
  10:     
  11:         ...
  12:                 final MultiPixelPackedSampleModel cast = (MultiPixelPackedSampleModel) model;
  13:                 final int numberOfBits   = DataBuffer.getDataTypeSize(dataType);

View Full Code Here
   1: import java.awt.image.ComponentColorModel;
   2: import java.awt.image.DataBuffer;
   3: import java.awt.image.Raster;
   4:         ...
   5:     private final static ComponentColorModel cm = RasterFactory
   6:             .createComponentColorModel(DataBuffer.TYPE_FLOAT,
   7: 
   8:         ...
   9:         final int dataType = sm.getDataType();
  10:         final int sampleSizeBit = DataBuffer.getDataTypeSize(dataType);
  11:         final int sampleSizeByte = (sampleSizeBit + 7) / 8;

View Full Code Here
   1: import java.awt.Image;
   2: import java.awt.image.DataBuffer;
   3: import java.awt.image.ColorModel;
   4:         ...
   5:         switch (type) {
   6:             case DataBuffer.TYPE_USHORT:    key=VocabularyKeys.UNSIGNED_INTEGER_$2; break;
   7:         ...
   8:             case DataBuffer.TYPE_INT:       key=VocabularyKeys.SIGNED_INTEGER_$1; break;
   9:             case DataBuffer.TYPE_DOUBLE:    key=VocabularyKeys.REAL_NUMBER_$1; break;
  10:         ...
  11:         }
  12:         final Integer  typeSize = new Integer(DataBuffer.getDataTypeSize(type));

View Full Code Here
   1: import java.awt.Image;
   2: import java.awt.image.DataBuffer;
   3: import java.awt.image.ColorModel;
   4:         ...
   5:         switch (type) {
   6:             case DataBuffer.TYPE_USHORT:    key=ResourceKeys.UNSIGNED_INTEGER_$2; break;
   7:         ...
   8:             case DataBuffer.TYPE_INT:       key=ResourceKeys.SIGNED_INTEGER_$1; break;
   9:             case DataBuffer.TYPE_DOUBLE:    key=ResourceKeys.REAL_NUMBER_$1; break;
  10:         ...
  11:         }
  12:         final Integer  typeSize = new Integer(DataBuffer.getDataTypeSize(type));

View Full Code Here

getElem

public int getElem(int i)
Returns the requested data array element from the first (default) bank as an integer.
Parameters:
i - the index of the requested data array element
Returns:
the data array element at the specified index.
Usages and Demos :

View More Examples of getElem(int i)
   1: import java.awt.image.BufferedImage;
   2: import java.awt.image.DataBuffer;
   3: 
   4:         ...
   5:             
   6:             DataBuffer src = img.getAlphaRaster().getDataBuffer();
   7:             
   8:         ...
   9:             BufferedImage progress = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
  10:             DataBuffer dst = progress.getAlphaRaster().getDataBuffer();
  11:             
  12:         ...
  13:                     
  14:                     int value = src.getElem(index);

View Full Code Here

getElem

public abstract int getElem(int bank,
                            int i)
Returns the requested data array element from the specified bank as an integer.
Parameters:
bank - the specified bank
i - the index of the requested data array element
Returns:
the data array element at the specified index from the specified bank at the specified index.

getElemDouble

public double getElemDouble(int i)
Returns the requested data array element from the first (default) bank as a double. The implementation in this class is to cast getElem(int) to a double. Subclasses can override this method if another implementation is needed.
Parameters:
i - the specified index
Returns:
a double value representing the element at the specified index in the data array.

getElemDouble

public double getElemDouble(int bank,
                            int i)
Returns the requested data array element from the specified bank as a double. The implementation in this class is to cast getElem(bank, i) to a double. Subclasses may override this method if another implementation is needed.
Parameters:
bank - the specified bank
i - the specified index
Returns:
a double value representing the element from the specified bank at the specified index in the data array.
Usages and Demos :

View More Examples of getElemDouble(int bank,int i)
   1: import java.awt.image.ComponentColorModel;
   2: import java.awt.image.DataBuffer;
   3: import java.awt.image.DataBufferByte;
   4:         ...
   5:         final int      streamDataType = streamModel.getDataType();
   6:         final int  streamWidthInBytes = streamWidth * DataBuffer.getDataTypeSize(streamDataType) / 8;
   7:         final BufferedImage     image = getDestination(imageIndex, param, sourceBands, destinationBands, streamModel, streamWidth, streamHeight);
   8:         ...
   9:         final WritableRaster srcRaster = isDirect ? dstRaster : WritableRaster.createWritableRaster(streamModel.createCompatibleSampleModel(streamWidth, Math.min(8, streamHeight)), null);
  10:         final DataBuffer        buffer = srcRaster.getDataBuffer();
  11:         final int         bufferHeight = srcRaster.getHeight();
  12:         ...
  13:                         for (int i=offset; i<stop; i++) {
  14:                             double value = buffer.getElemDouble(srcBand, i);

View Full Code Here
   1: 
   2: import java.awt.image.DataBuffer;
   3: import java.awt.image.DataBufferInt;
   4:         ...
   5:         final int      streamDataType = streamModel.getDataType();
   6:         final int  streamWidthInBytes = streamWidth * DataBuffer.getDataTypeSize(streamDataType) / 8;
   7:         final BufferedImage     image = getDestination(imageIndex, param, sourceBands, destinationBands, streamModel, streamWidth, streamHeight);
   8:         ...
   9:         final WritableRaster srcRaster = isDirect ? dstRaster : WritableRaster.createWritableRaster(streamModel.createCompatibleSampleModel(streamWidth, Math.min(8, streamHeight)), null);
  10:         final DataBuffer        buffer = srcRaster.getDataBuffer();
  11:         final int         bufferHeight = srcRaster.getHeight();
  12:         ...
  13:                         for (int i=offset; i<stop; i++) {
  14:                             double value = buffer.getElemDouble(srcBand, i);

View Full Code Here

getElemFloat

public float getElemFloat(int i)
Returns the requested data array element from the first (default) bank as a float. The implementation in this class is to cast getElem(i) to a float. Subclasses may override this method if another implementation is needed.
Parameters:
i - the index of the requested data array element
Returns:
a float value representing the data array element at the specified index.

getElemFloat

public float getElemFloat(int bank,
                          int i)
Returns the requested data array element from the specified bank as a float. The implementation in this class is to cast getElem(int,int) to a float. Subclasses can override this method if another implementation is needed.
Parameters:
bank - the specified bank
i - the index of the requested data array element
Returns:
a float value representing the data array element from the specified bank at the specified index.

getNumBanks

public int getNumBanks()
Returns the number of banks in this DataBuffer.
Returns:
the number of banks.
Usages and Demos :

View More Examples of getNumBanks()
   1: import java.awt.image.ComponentSampleModel;
   2: import java.awt.image.DataBuffer;
   3: import java.awt.image.DataBufferByte;
   4:         ...
   5: 
   6:     private static Object getBankReference(DataBuffer db) {
   7:         Object array = null;
   8:         ...
   9:         switch (db.getDataType()) {
  10:         case DataBuffer.TYPE_BYTE:
  11:             array = ((DataBufferByte) db).getBankData();
  12:         ...
  13:         Long key = new Long(((long) db.getDataType() << 56)
  14:                 | ((long) db.getNumBanks() << 32) | (long) db.getSize());

View Full Code Here
   1: import java.awt.image.ComponentSampleModel;
   2: import java.awt.image.DataBuffer;
   3: import java.awt.image.DataBufferByte;
   4:         ...
   5: 
   6:     private static Object getBankReference(DataBuffer db) {
   7:         Object array = null;
   8:         ...
   9:         switch (db.getDataType()) {
  10:         case DataBuffer.TYPE_BYTE:
  11:             array = ((DataBufferByte) db).getBankData();
  12:         ...
  13:         Long key = new Long(((long) db.getDataType() << 56)
  14:                 | ((long) db.getNumBanks() << 32) | (long) db.getSize());

View Full Code Here
   1: import java.awt.image.CropImageFilter;
   2: import java.awt.image.DataBuffer;
   3: import java.awt.image.DataBufferInt;
   4:         ...
   5:     WritableRaster raster = bimage.getRaster();              
   6:     DataBuffer db = raster.getDataBuffer ();
   7: 
   8:         ...
   9: 
  10:     if (raster.getSampleModel ().getDataType () == DataBuffer.TYPE_INT 
  11:         && db instanceof DataBufferInt 
  12:         ...
  13:         && db.getNumBanks() == 1)

View Full Code Here

getOffset

public int getOffset()
Returns the offset of the default bank in array elements.
Returns:
the offset of the default bank.
Usages and Demos :

View More Examples of getOffset()
   1: import java.awt.image.ComponentSampleModel;
   2: import java.awt.image.DataBuffer;
   3: import java.awt.image.Raster;
   4:         ...
   5: 
   6:         DataBuffer srcDB = src.getDataBuffer();
   7:         ...
   8:         DataBuffer destDB = dest.getDataBuffer();

View Full Code Here
   1: 
   2:     DataBuffer dataB = raster.getDataBuffer();
   3:     attachData(ximg, dataB, 0);
   4:         ...
   5:       Buffers.smallestAppropriateTransferType(bitsPerPixel);
   6:     int bitsPerDataElement = DataBuffer.getDataTypeSize(dataType);
   7:     int scanlineStride = ximage.getBytesPerLine()*8/bitsPerDataElement;
   8:         ...
   9: 
  10:   static void attachData(XImage ximage, DataBuffer dataB, int offset)
  11:   {
  12:         ...
  13:     offset += dataB.getOffset();

View Full Code Here

getOffsets

public int[] getOffsets()
Returns the offsets (in array elements) of all the banks.
Returns:
the offsets of all banks.

getSize

public int getSize()
Returns the size (in array elements) of all banks.
Returns:
the size of all banks.
Usages and Demos :

View More Examples of getSize()
   1: import java.awt.image.ComponentSampleModel;
   2: import java.awt.image.DataBuffer;
   3: import java.awt.image.DataBufferByte;
   4:         ...
   5: 
   6:     private static Object getBankReference(DataBuffer db) {
   7:         Object array = null;
   8:         ...
   9:         switch (db.getDataType()) {
  10:         case DataBuffer.TYPE_BYTE:
  11:             array = ((DataBufferByte) db).getBankData();
  12:         ...
  13:         Long key = new Long(((long) db.getDataType() << 56)
  14:                 | ((long) db.getNumBanks() << 32) | (long) db.getSize());

View Full Code Here
   1: import java.awt.image.ComponentSampleModel;
   2: import java.awt.image.DataBuffer;
   3: import java.awt.image.DataBufferByte;
   4:         ...
   5: 
   6:     private static Object getBankReference(DataBuffer db) {
   7:         Object array = null;
   8:         ...
   9:         switch (db.getDataType()) {
  10:         case DataBuffer.TYPE_BYTE:
  11:             array = ((DataBufferByte) db).getBankData();
  12:         ...
  13:         Long key = new Long(((long) db.getDataType() << 56)
  14:                 | ((long) db.getNumBanks() << 32) | (long) db.getSize());

View Full Code Here

setElem

public void setElem(int i,
                    int val)
Sets the requested data array element in the first (default) bank from the given integer.
Parameters:
i - the specified index into the data array
val - the data to set the element at the specified index in the data array
Usages and Demos :

View More Examples of setElem(int i,int val)
   1: import java.awt.image.BufferedImage;
   2: import java.awt.image.DataBuffer;
   3: import java.awt.image.FilteredImageSource;
   4:         ...
   5: 
   6:         DataBuffer db = bufferedImage.getRaster().getDataBuffer();
   7:         for (int i = 0, c = db.getSize(); i < c; i++) {
   8:         ...
   9:             if (db.getElem(i) == TRANSPARENT_TO_REMOVE) {
  10:                 db.setElem(i, TRANSPARENT_PIXEL);
  11:             }

View Full Code Here

setElem

public abstract void setElem(int bank,
                             int i,
                             int val)
Sets the requested data array element in the specified bank from the given integer.
Parameters:
bank - the specified bank
i - the specified index into the data array
val - the data to set the element in the specified bank at the specified index in the data array

setElemDouble

public void setElemDouble(int i,
                          double val)
Sets the requested data array element in the first (default) bank from the given double. The implementation in this class is to cast val to an int and call setElem(int,int). Subclasses can override this method if another implementation is needed.
Parameters:
i - the specified index
val - the value to set the element at the specified index in the data array

setElemDouble

public void setElemDouble(int bank,
                          int i,
                          double val)
Sets the requested data array element in the specified bank from the given double. The implementation in this class is to cast val to an int and call setElem(int,int). Subclasses can override this method if another implementation is needed.
Parameters:
bank - the specified bank
i - the specified index
val - the value to set the element in the specified bank at the specified index of the data array
Usages and Demos :

View More Examples of setElemDouble(int bank,int i,double val)
   1: import java.awt.image.ComponentColorModel;
   2: import java.awt.image.DataBuffer;
   3: import java.awt.image.DataBufferByte;
   4:         ...
   5:         final int      streamDataType = streamModel.getDataType();
   6:         final int  streamWidthInBytes = streamWidth * DataBuffer.getDataTypeSize(streamDataType) / 8;
   7:         final BufferedImage     image = getDestination(imageIndex, param, sourceBands, destinationBands, streamModel, streamWidth, streamHeight);
   8:         ...
   9:         final WritableRaster srcRaster = isDirect ? dstRaster : WritableRaster.createWritableRaster(streamModel.createCompatibleSampleModel(streamWidth, Math.min(8, streamHeight)), null);
  10:         final DataBuffer        buffer = srcRaster.getDataBuffer();
  11:         final int         bufferHeight = srcRaster.getHeight();
  12:         ...
  13:                             }
  14:                             buffer.setElemDouble(srcBand, i, value);

View Full Code Here
   1: 
   2: import java.awt.image.DataBuffer;
   3: import java.awt.image.DataBufferInt;
   4:         ...
   5:         final int      streamDataType = streamModel.getDataType();
   6:         final int  streamWidthInBytes = streamWidth * DataBuffer.getDataTypeSize(streamDataType) / 8;
   7:         final BufferedImage     image = getDestination(imageIndex, param, sourceBands, destinationBands, streamModel, streamWidth, streamHeight);
   8:         ...
   9:         final WritableRaster srcRaster = isDirect ? dstRaster : WritableRaster.createWritableRaster(streamModel.createCompatibleSampleModel(streamWidth, Math.min(8, streamHeight)), null);
  10:         final DataBuffer        buffer = srcRaster.getDataBuffer();
  11:         final int         bufferHeight = srcRaster.getHeight();
  12:         ...
  13:                             }
  14:                             buffer.setElemDouble(srcBand, i, value);

View Full Code Here

setElemFloat

public void setElemFloat(int i,
                         float val)
Sets the requested data array element in the first (default) bank from the given float. The implementation in this class is to cast val to an int and call setElem(int,int). Subclasses can override this method if another implementation is needed.
Parameters:
i - the specified index
val - the value to set the element at the specified index in the data array

setElemFloat

public void setElemFloat(int bank,
                         int i,
                         float val)
Sets the requested data array element in the specified bank from the given float. The implementation in this class is to cast val to an int and call setElem(int,int). Subclasses can override this method if another implementation is needed.
Parameters:
bank - the specified bank
i - the specified index
val - the value to set the element in the specified bank at the specified index in the data array