< prev index next >
src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java
Print this page
@@ -1087,10 +1087,19 @@
* are treated as unsigned; that is, no sign extension will take
* place and the returned value will be in the range [0, 255].
* {@code TIFF_SBYTE} data will be returned in the range
* [-128, 127].
*
+ * <p> Data in {@code TIFF_FLOAT} and {@code TIFF_DOUBLE} are
+ * simply cast to {@code long} and may suffer from truncation.
+ *
+ * <p> Data in {@code TIFF_SRATIONAL} or
+ * {@code TIFF_RATIONAL} format are evaluated by dividing the
+ * numerator into the denominator using double-precision
+ * arithmetic and then casting to {@code long}. Loss of
+ * precision and truncation may occur.
+ *
* <p> Data in {@code TIFF_ASCII} format will be parsed as by
* the {@code Double.parseDouble} method, with the result
* cast to {@code long}.
*
* @param index The index of the data.
@@ -1110,10 +1119,14 @@
case TIFFTag.TIFF_SLONG:
return ((int[])data)[index];
case TIFFTag.TIFF_LONG:
case TIFFTag.TIFF_IFD_POINTER:
return ((long[])data)[index];
+ case TIFFTag.TIFF_FLOAT:
+ return (long)((float[])data)[index];
+ case TIFFTag.TIFF_DOUBLE:
+ return (long)((double[])data)[index];
case TIFFTag.TIFF_SRATIONAL:
int[] ivalue = getAsSRational(index);
return (long)((double)ivalue[0]/ivalue[1]);
case TIFFTag.TIFF_RATIONAL:
long[] lvalue = getAsRational(index);
< prev index next >