| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
package com.drew.imaging.tiff; |
| 22 |
|
| 23 |
import com.drew.lang.annotations.NotNull; |
| 24 |
import com.drew.lang.annotations.Nullable; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public class TiffDataFormat |
| 32 |
{ |
| 33 |
public static final int CODE_INT8_U = 1; |
| 34 |
public static final int CODE_STRING = 2; |
| 35 |
public static final int CODE_INT16_U = 3; |
| 36 |
public static final int CODE_INT32_U = 4; |
| 37 |
public static final int CODE_RATIONAL_U = 5; |
| 38 |
public static final int CODE_INT8_S = 6; |
| 39 |
public static final int CODE_UNDEFINED = 7; |
| 40 |
public static final int CODE_INT16_S = 8; |
| 41 |
public static final int CODE_INT32_S = 9; |
| 42 |
public static final int CODE_RATIONAL_S = 10; |
| 43 |
public static final int CODE_SINGLE = 11; |
| 44 |
public static final int CODE_DOUBLE = 12; |
| 45 |
|
| 46 |
@NotNull public static final TiffDataFormat INT8_U = new TiffDataFormat("BYTE", CODE_INT8_U, 1); |
| 47 |
@NotNull public static final TiffDataFormat STRING = new TiffDataFormat("STRING", CODE_STRING, 1); |
| 48 |
@NotNull public static final TiffDataFormat INT16_U = new TiffDataFormat("USHORT", CODE_INT16_U, 2); |
| 49 |
@NotNull public static final TiffDataFormat INT32_U = new TiffDataFormat("ULONG", CODE_INT32_U, 4); |
| 50 |
@NotNull public static final TiffDataFormat RATIONAL_U = new TiffDataFormat("URATIONAL", CODE_RATIONAL_U, 8); |
| 51 |
@NotNull public static final TiffDataFormat INT8_S = new TiffDataFormat("SBYTE", CODE_INT8_S, 1); |
| 52 |
@NotNull public static final TiffDataFormat UNDEFINED = new TiffDataFormat("UNDEFINED", CODE_UNDEFINED, 1); |
| 53 |
@NotNull public static final TiffDataFormat INT16_S = new TiffDataFormat("SSHORT", CODE_INT16_S, 2); |
| 54 |
@NotNull public static final TiffDataFormat INT32_S = new TiffDataFormat("SLONG", CODE_INT32_S, 4); |
| 55 |
@NotNull public static final TiffDataFormat RATIONAL_S = new TiffDataFormat("SRATIONAL", CODE_RATIONAL_S, 8); |
| 56 |
@NotNull public static final TiffDataFormat SINGLE = new TiffDataFormat("SINGLE", CODE_SINGLE, 4); |
| 57 |
@NotNull public static final TiffDataFormat DOUBLE = new TiffDataFormat("DOUBLE", CODE_DOUBLE, 8); |
| 58 |
|
| 59 |
@NotNull |
| 60 |
private final String _name; |
| 61 |
private final int _tiffFormatCode; |
| 62 |
private final int _componentSizeBytes; |
| 63 |
|
| 64 |
@Nullable |
| 65 |
public static TiffDataFormat fromTiffFormatCode(int tiffFormatCode) |
| 66 |
{ |
| 67 |
switch (tiffFormatCode) { |
| 68 |
case 1: return INT8_U; |
| 69 |
case 2: return STRING; |
| 70 |
case 3: return INT16_U; |
| 71 |
case 4: return INT32_U; |
| 72 |
case 5: return RATIONAL_U; |
| 73 |
case 6: return INT8_S; |
| 74 |
case 7: return UNDEFINED; |
| 75 |
case 8: return INT16_S; |
| 76 |
case 9: return INT32_S; |
| 77 |
case 10: return RATIONAL_S; |
| 78 |
case 11: return SINGLE; |
| 79 |
case 12: return DOUBLE; |
| 80 |
} |
| 81 |
return null; |
| 82 |
} |
| 83 |
|
| 84 |
private TiffDataFormat(@NotNull String name, int tiffFormatCode, int componentSizeBytes) |
| 85 |
{ |
| 86 |
_name = name; |
| 87 |
_tiffFormatCode = tiffFormatCode; |
| 88 |
_componentSizeBytes = componentSizeBytes; |
| 89 |
} |
| 90 |
|
| 91 |
public int getComponentSizeBytes() |
| 92 |
{ |
| 93 |
return _componentSizeBytes; |
| 94 |
} |
| 95 |
|
| 96 |
public int getTiffFormatCode() |
| 97 |
{ |
| 98 |
return _tiffFormatCode; |
| 99 |
} |
| 100 |
|
| 101 |
@Override |
| 102 |
@NotNull |
| 103 |
public String toString() |
| 104 |
{ |
| 105 |
return _name; |
| 106 |
} |
| 107 |
} |