Package org.apache.sis.image
Class TransferType<T extends Buffer>
- Object
-
- TransferType<T>
-
- Type Parameters:
T
- the type of buffer which can be used for transferring data.
- All Implemented Interfaces:
Serializable
public final class TransferType<T extends Buffer> extends Object implements Serializable
The type of data used to transfer pixels. Data transfers happen in variousRaster
methods and inPixelIterator.createWindow(TransferType)
. The type used for transferring data is not necessarily the same than the type used by the raster for storing data. In particular,byte
andshort
(both signed and unsigned) are converted toint
during the transfer.Raster
andPixelIterator
transfer data inint[]
,float[]
anddouble[]
arrays. Additionally,PixelIterator
uses alsoIntBuffer
,FloatBuffer
andDoubleBuffer
.Future evolution: this class may be refactored as an enumeration in a future Java version if JEP 301 is implemented.- Since:
- 1.0
- See Also:
Raster.getTransferType()
,PixelIterator.createWindow(TransferType)
, Serialized Form
Defined in the
sis-feature
module
-
-
Field Summary
Fields Modifier and Type Field Description static TransferType<DoubleBuffer>
DOUBLE
Specifies that sample values are transfered as double-precision floating point number.static TransferType<FloatBuffer>
FLOAT
Specifies that sample values are transfered as single-precision floating point number.static TransferType<IntBuffer>
INT
Specifies that sample values are transfered as 32 bits signed integer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
toString()
Returns the name of this enumeration constant.static TransferType<?>
valueOf(int type)
Returns the enumeration value for the givenDataBuffer
constant.
-
-
-
Field Detail
-
INT
public static final TransferType<IntBuffer> INT
Specifies that sample values are transfered as 32 bits signed integer. If the raster stores sample values asbyte
orshort
, the values are casted by a widening conversion before to be transfered. If the raster stores sample values asfloat
ordouble
, the values are rounded toward 0 before to be transfered.
-
FLOAT
public static final TransferType<FloatBuffer> FLOAT
Specifies that sample values are transfered as single-precision floating point number. Values of other types are casted as needed.
-
DOUBLE
public static final TransferType<DoubleBuffer> DOUBLE
Specifies that sample values are transfered as double-precision floating point number. Values of other types are casted as needed. This is the safest transfer type to use when wanting to avoid any precision lost.
-
-
Method Detail
-
valueOf
public static TransferType<?> valueOf(int type)
Returns the enumeration value for the givenDataBuffer
constant. This method applies the following mapping:- If
type
isDataBuffer.TYPE_DOUBLE
, returnsDOUBLE
. - If
type
isDataBuffer.TYPE_FLOAT
, returnsFLOAT
. - If
type
isDataBuffer.TYPE_INT
,TYPE_SHORT
,TYPE_USHORT
orTYPE_BYTE
, returnsINT
. - If
type
isDataBuffer.TYPE_UNDEFINED
or any other value, throwsIllegalArgumentException
.
type
argument given to this method is typically theRaster.getTransferType()
value.- Parameters:
type
- one ofDataBuffer
constant.- Returns:
- the enumeration value for the given constant.
- Throws:
IllegalArgumentException
- if (@code type} is not a supportedDataBuffer
constant.
- If
-
-