Class DataBlk
- Direct Known Subclasses:
DataBlkFloat,DataBlkInt
The data is always stored in one array, of the type matching the data type (i.e. for 'int' it's an 'int[]'). The data should be stored in the array in standard scan-line order. That is the samples go from the top-left corner of the code-block to the lower-right corner by line and then column.
The member variable 'offset' gives the index in the array of the first data element (i.e. the top-left coefficient (ulx,uly)). The member variable 'scanw' gives the width of the scan that is used to store the data, that can be different from the width of the block. Element '(x,y)' of the code-block (i.e. '(ulx,uly)' is the top-left coefficient), will appear at position 'offset+(y-uly)*scanw+(x-ulx)' in the array of data.
A block of data can have the progressive attribute set. Data is progressive when it is obtained by successive refinement and the values in this block are approximations of the "final" values. When the final values are returned the progressive attribute must be turned off.
The classes DataBlkInt and DataBlkFloat provide implementations for int and float types respectively.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionintThe height of the block, in pixels.intThe offset in the array of the top-left coefficientbooleanThe progressive attribute (false by default)intThe width of the scanlines used to store the data in the arraystatic final intThe identifier for the byte data type, as signed 8 bits.static final intThe identifier for the float data typestatic final intThe identifier for the int data type, as signed 32 bits.static final intThe identifier for the short data type, as signed 16 bits.intThe horizontal coordinate (in pixels) of the upper-left corner of the block of data.intThe vertical coordinate of the upper-left corner of the block of data.intThe width of the block, in pixels. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract ObjectgetData()Returns the array containing the data, or null if there is no data.abstract intReturns the data type of the DataBlk object, as defined in this class.static intgetSize(int type) Returns the size in bits, given the data type.abstract voidSets the data array to the specified one.toString()Returns a string of informations about the DataBlk
-
Field Details
-
TYPE_BYTE
public static final int TYPE_BYTEThe identifier for the byte data type, as signed 8 bits.- See Also:
-
TYPE_SHORT
public static final int TYPE_SHORTThe identifier for the short data type, as signed 16 bits.- See Also:
-
TYPE_INT
public static final int TYPE_INTThe identifier for the int data type, as signed 32 bits.- See Also:
-
TYPE_FLOAT
public static final int TYPE_FLOATThe identifier for the float data type- See Also:
-
ulx
public int ulxThe horizontal coordinate (in pixels) of the upper-left corner of the block of data. This is relative to the component of the image from where this block was filled or is to be filled. -
uly
public int ulyThe vertical coordinate of the upper-left corner of the block of data. This is relative to the component of the image from where this block was filled or is to be filled. -
w
public int wThe width of the block, in pixels. -
h
public int hThe height of the block, in pixels. -
offset
public int offsetThe offset in the array of the top-left coefficient -
scanw
public int scanwThe width of the scanlines used to store the data in the array -
progressive
public boolean progressiveThe progressive attribute (false by default)
-
-
Constructor Details
-
DataBlk
public DataBlk()
-
-
Method Details
-
getSize
public static int getSize(int type) Returns the size in bits, given the data type. The data type must be one defined in this class. An IllegalArgumentException is thrown if type is not defined in this class.- Parameters:
type- The data type.- Returns:
- The size in bits of the data type.
-
getDataType
public abstract int getDataType()Returns the data type of the DataBlk object, as defined in this class.- Returns:
- The data type of the object, as defined in thsi class.
-
getData
Returns the array containing the data, or null if there is no data. The returned array is of the type returned by getDataType() (e.g., for TYPE_INT, it is a int[]).Each implementing class should provide a type specific equivalent method (e.g., getDataInt() in DataBlkInt) which returns an array of the correct type explicetely and not through an Object.
- Returns:
- The array containing the data, or null if there is no data.
- See Also:
-
setData
Sets the data array to the specified one. The type of the specified data array must match the one returned by getDataType() (e.g., for TYPE_INT, it should be a int[]). If the wrong type of array is given a ClassCastException will be thrown.The size of the array is not necessarily checked for consistency with w and h or any other fields.
Each implementing class should provide a type specific equivalent method (e.g., setDataInt() in DataBlkInt) which takes an array of the correct type explicetely and not through an Object.
- Parameters:
arr- The new data array to use- See Also:
-
toString
Returns a string of informations about the DataBlk
-