| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
package com.drew.metadata.exif.makernotes; |
| 22 |
|
| 23 |
import com.drew.lang.Rational; |
| 24 |
import com.drew.lang.annotations.NotNull; |
| 25 |
import com.drew.lang.annotations.Nullable; |
| 26 |
import com.drew.metadata.TagDescriptor; |
| 27 |
|
| 28 |
import static com.drew.metadata.exif.makernotes.OlympusRawInfoMakernoteDirectory.*; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
@SuppressWarnings("WeakerAccess") |
| 41 |
public class OlympusRawInfoMakernoteDescriptor extends TagDescriptor<OlympusRawInfoMakernoteDirectory> |
| 42 |
{ |
| 43 |
public OlympusRawInfoMakernoteDescriptor(@NotNull OlympusRawInfoMakernoteDirectory directory) |
| 44 |
{ |
| 45 |
super(directory); |
| 46 |
} |
| 47 |
|
| 48 |
@Override |
| 49 |
@Nullable |
| 50 |
public String getDescription(int tagType) |
| 51 |
{ |
| 52 |
switch (tagType) { |
| 53 |
case TagRawInfoVersion: |
| 54 |
return getVersionBytesDescription(TagRawInfoVersion, 4); |
| 55 |
case TagColorMatrix2: |
| 56 |
return getColorMatrix2Description(); |
| 57 |
case TagYCbCrCoefficients: |
| 58 |
return getYCbCrCoefficientsDescription(); |
| 59 |
case TagLightSource: |
| 60 |
return getOlympusLightSourceDescription(); |
| 61 |
default: |
| 62 |
return super.getDescription(tagType); |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
@Nullable |
| 67 |
public String getColorMatrix2Description() |
| 68 |
{ |
| 69 |
int[] values = _directory.getIntArray(TagColorMatrix2); |
| 70 |
if (values == null) |
| 71 |
return null; |
| 72 |
|
| 73 |
StringBuilder sb = new StringBuilder(); |
| 74 |
for (int i = 0; i < values.length; i++) { |
| 75 |
sb.append((short)values[i]); |
| 76 |
if (i < values.length - 1) |
| 77 |
sb.append(" "); |
| 78 |
} |
| 79 |
return sb.length() == 0 ? null : sb.toString(); |
| 80 |
} |
| 81 |
|
| 82 |
@Nullable |
| 83 |
public String getYCbCrCoefficientsDescription() |
| 84 |
{ |
| 85 |
int[] values = _directory.getIntArray(TagYCbCrCoefficients); |
| 86 |
if (values == null) |
| 87 |
return null; |
| 88 |
|
| 89 |
Rational[] ret = new Rational[values.length / 2]; |
| 90 |
for(int i = 0; i < values.length / 2; i++) |
| 91 |
{ |
| 92 |
ret[i] = new Rational((short)values[2*i], (short)values[2*i + 1]); |
| 93 |
} |
| 94 |
|
| 95 |
StringBuilder sb = new StringBuilder(); |
| 96 |
for (int i = 0; i < ret.length; i++) { |
| 97 |
sb.append(ret[i].doubleValue()); |
| 98 |
if (i < ret.length - 1) |
| 99 |
sb.append(" "); |
| 100 |
} |
| 101 |
return sb.length() == 0 ? null : sb.toString(); |
| 102 |
} |
| 103 |
|
| 104 |
@Nullable |
| 105 |
public String getOlympusLightSourceDescription() |
| 106 |
{ |
| 107 |
Integer value = _directory.getInteger(TagLightSource); |
| 108 |
if (value == null) |
| 109 |
return null; |
| 110 |
|
| 111 |
switch (value.shortValue()) |
| 112 |
{ |
| 113 |
case 0: |
| 114 |
return "Unknown"; |
| 115 |
case 16: |
| 116 |
return "Shade"; |
| 117 |
case 17: |
| 118 |
return "Cloudy"; |
| 119 |
case 18: |
| 120 |
return "Fine Weather"; |
| 121 |
case 20: |
| 122 |
return "Tungsten (Incandescent)"; |
| 123 |
case 22: |
| 124 |
return "Evening Sunlight"; |
| 125 |
case 33: |
| 126 |
return "Daylight Fluorescent"; |
| 127 |
case 34: |
| 128 |
return "Day White Fluorescent"; |
| 129 |
case 35: |
| 130 |
return "Cool White Fluorescent"; |
| 131 |
case 36: |
| 132 |
return "White Fluorescent"; |
| 133 |
case 256: |
| 134 |
return "One Touch White Balance"; |
| 135 |
case 512: |
| 136 |
return "Custom 1-4"; |
| 137 |
default: |
| 138 |
return "Unknown (" + value + ")"; |
| 139 |
} |
| 140 |
} |
| 141 |
} |