Package org.apache.sis.image
Enum Class DataType
- All Implemented Interfaces:
- Serializable,- Comparable<DataType>,- Constable
Identification of the primitive type used for storing sample values in an image.
 This is a type-safe version of the 
TYPE_* constants defined in DataBuffer.- Since:
- 1.1
Defined in the sis-feature module
- 
Nested Class SummaryNested classes/interfaces inherited from class EnumEnum.EnumDesc<E extends Enum<E>>
- 
Enum Constant SummaryEnum Constants
- 
Method SummaryModifier and TypeMethodDescriptionfinal intbytes()Returns the size in bytes of this data type.static DataTypeforBands(RenderedImage image) Returns the data type of the bands in the given image.static DataTypeforDataBufferType(int type) Returns the enumeration value for the givenDataBufferconstant.static DataTypeforNumberOfBits(int size, boolean real, boolean signed) Returns the enumeration value for the given number of bits.static DataTypeforPrimitiveType(Class<?> type, boolean unsigned) Returns the data type for the given primitive type.static DataTypeforRange(NumberRange<?> range, boolean asInteger) Returns the smallest data type capable to store the given range of values.final booleanReturns whether this type is an integer type, signed or not.final booleanReturns whether this type is an unsigned integer type.final intsize()Returns the size in bits of this data type.final intReturns theDataBufferconstant for this enumeration value.final DataTypetoFloat()Returns the smallest floating point type capable to store all values of this type without precision lost.static DataTypeReturns the enum constant of this class with the specified name.static DataType[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class Enumclone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
- 
Enum Constant Details- 
BYTEUnsigned 8-bits data.
- 
USHORTUnsigned 16-bits data.
- 
SHORTSigned 16-bits data.
- 
INTSigned 32-bits data. Also used for storing unsigned data; the Java2D API such asRaster.getSample(int, int, int)cannot distinguish the two cases.
- 
FLOATSingle precision (32-bits) floating point data.
- 
DOUBLEDouble precision (64-bits) floating point data.
 
- 
- 
Method Details- 
valuesReturns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
 
- 
valueOfReturns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
- name- the name of the enum constant to be returned.
- Returns:
- the enum constant with the specified name
- Throws:
- IllegalArgumentException- if this enum class has no constant with the specified name
- NullPointerException- if the argument is null
 
- 
forBandsReturns the data type of the bands in the given image. This is often the storage data type, but not necessarily. For example if an ARGB image uses a storage mode where the sample values in the 4 bands are packed in a single 32-bits integer, then this method returnsBYTE(the type of a single band), notINT(the type of a whole pixel).- Parameters:
- image- the image for which to get the type.
- Returns:
- type of the given image (never null).
- Throws:
- RasterFormatException- if the image does not use a recognized data type.
 
- 
forRangeReturns the smallest data type capable to store the given range of values. If the given range uses a floating point type, there there is a choice:- Parameters:
- range- the range of values.
- asInteger- whether to handle floating point values as integers.
- Returns:
- smallest data type for the given range of values.
 
- 
forPrimitiveTypeReturns the data type for the given primitive type. The giventypeshould be a primitive type such asShort.TYPE, but wrappers class such asShort.classare also accepted.- Parameters:
- type- the primitive type or its wrapper class.
- unsigned- whether the type should be considered unsigned.
- Returns:
- the data type (never null) for the given primitive type.
- Throws:
- RasterFormatException- if the given type is not a recognized.
 
- 
forDataBufferTypeReturns the enumeration value for the givenDataBufferconstant. This method is the converse oftoDataBufferType(). It is provided for interoperability with Java2D.- Parameters:
- type- one of- DataBuffer.TYPE_*constants.
- Returns:
- the data type (never null) for the given data buffer type.
- Throws:
- RasterFormatException- if the given type is not a recognized- DataBuffer.TYPE_*constant.
 
- 
forNumberOfBitsReturns the enumeration value for the given number of bits. Only the following combinations of argument values are accepted:Valid combinations of argument values size real signed 1 falsefalse2 falsefalse4 falsefalse8 falsefalse16 falsefalseortrue32 falsetrue32 trueignored 64 trueignored - Parameters:
- size- number of bits as a power of 2 between 1 and 64 inclusive.
- real-- truefor floating point numbers or- falsefor integers.
- signed-- truefor signed numbers of- falsefor unsigned numbers.
- Returns:
- the data type (never null) for the given number of bits.
- Throws:
- RasterFormatException- if the combination of argument values is invalid.
- Since:
- 1.2
 
- 
sizepublic final int size()Returns the size in bits of this data type.- Returns:
- size in bits of this data type.
 
- 
bytespublic final int bytes()Returns the size in bytes of this data type. If the number of bits is smaller than 8, then this method returns 1.- Returns:
- size in bytes of this data type, not smaller than 1.
- Since:
- 1.3
 
- 
isUnsignedpublic final boolean isUnsigned()- Returns:
- trueif this type is an unsigned integer type.
 
- 
isIntegerpublic final boolean isInteger()Returns whether this type is an integer type, signed or not. Integer types areBYTE,USHORT,SHORTandINT.- Returns:
- trueif this type is an integer type.
 
- 
toFloatReturns the smallest floating point type capable to store all values of this type without precision lost. This method returns: The promotion of integer values to floating point values is sometimes necessary when the image may containFloat.NaNvalues.
- 
toDataBufferTypepublic final int toDataBufferType()Returns theDataBufferconstant for this enumeration value. This method is the converse offorDataBufferType(int). It is provided for interoperability with Java2D.- Returns:
- one of the DataBufferconstants.
 
 
-