public float GetAsFloat(int index) {
switch (type) {
case TIFF_BYTE:
return ((byte[])data)[index] & 0xff;
case TIFF_SBYTE:
return ((byte[])data)[index];
case TIFF_SHORT:
return ((char[])data)[index] & 0xffff;
case TIFF_SSHORT:
return ((short[])data)[index];
case TIFF_SLONG:
return ((int[])data)[index];
case TIFF_LONG:
return ((long[])data)[index];
case TIFF_FLOAT:
return ((float[])data)[index];
case TIFF_DOUBLE:
return (float)((double[])data)[index];
case TIFF_SRATIONAL:
int[] ivalue = GetAsSRational(index);
return (float)((double)ivalue[0]/ivalue[1]);
case TIFF_RATIONAL:
long[] lvalue = GetAsRational(index);
return (float)((double)lvalue[0]/lvalue[1]);
default:
throw new InvalidCastException();
}
}