Package org.apache.sis.image
Class TransferType<T extends Buffer>
java.lang.Object
org.apache.sis.image.TransferType<T>
- Type Parameters:
T
- the type of buffer which can be used for transferring data.
- All Implemented Interfaces:
Serializable
The type of data used to transfer pixels. Data transfers happen in various
Raster
methods and in
PixelIterator.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
and short
(both signed and unsigned) are converted to int
during the transfer.
Raster
and PixelIterator
transfer data in int[]
, float[]
and double[]
arrays.
Additionally, PixelIterator
uses also IntBuffer
, FloatBuffer
and DoubleBuffer
.
Future evolution:
this class may be refactored as an enumeration in a future Java version if
JEP 301 is implemented.
- Since:
- 1.0
- Version:
- 1.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final int
The type as one of theDataBuffer
constants.static final TransferType<DoubleBuffer>
Specifies that sample values are transferred as double-precision floating point number.static final TransferType<FloatBuffer>
Specifies that sample values are transferred as single-precision floating point number.static final TransferType<IntBuffer>
Specifies that sample values are transferred as 32 bits signed integer.private final String
The enumeration name.private static final long
For cross-version compatibility. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
TransferType
(String name, int dataBufferType) Creates a new enumeration. -
Method Summary
Modifier and TypeMethodDescription(package private) Object
Returns a unique instance on deserialization.toString()
Returns the name of this enumeration constant.static TransferType<?>
valueOf
(int type) Returns the enumeration value for the givenDataBuffer
constant.
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
name
The enumeration name. -
dataBufferType
final int dataBufferTypeThe type as one of theDataBuffer
constants. This is the value returned byRaster.getTransferType()
. -
INT
Specifies that sample values are transferred as 32 bits signed integer. If the raster stores sample values asbyte
orshort
, the values are casted by a widening conversion before to be transferred. If the raster stores sample values asfloat
ordouble
, the values are rounded toward 0 before to be transferred. -
FLOAT
Specifies that sample values are transferred as single-precision floating point number. Values of other types are casted as needed. -
DOUBLE
Specifies that sample values are transferred 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.
-
-
Constructor Details
-
TransferType
Creates a new enumeration.
-
-
Method Details
-
valueOf
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
-
readResolve
Returns a unique instance on deserialization.- Returns:
- the object to use after deserialization.
- Throws:
ObjectStreamException
- if the serialized object defines an unknown data type.
-
toString
Returns the name of this enumeration constant.
-