| 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.jpeg; |
| 22 |
|
| 23 |
import com.drew.lang.annotations.NotNull; |
| 24 |
import com.drew.lang.annotations.Nullable; |
| 25 |
import com.drew.metadata.TagDescriptor; |
| 26 |
|
| 27 |
import static com.drew.metadata.jpeg.JpegDirectory.*; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
@SuppressWarnings("WeakerAccess") |
| 36 |
public class JpegDescriptor extends TagDescriptor<JpegDirectory> |
| 37 |
{ |
| 38 |
public JpegDescriptor(@NotNull JpegDirectory directory) |
| 39 |
{ |
| 40 |
super(directory); |
| 41 |
} |
| 42 |
|
| 43 |
@Override |
| 44 |
@Nullable |
| 45 |
public String getDescription(int tagType) |
| 46 |
{ |
| 47 |
switch (tagType) |
| 48 |
{ |
| 49 |
case TAG_COMPRESSION_TYPE: |
| 50 |
return getImageCompressionTypeDescription(); |
| 51 |
case TAG_COMPONENT_DATA_1: |
| 52 |
return getComponentDataDescription(0); |
| 53 |
case TAG_COMPONENT_DATA_2: |
| 54 |
return getComponentDataDescription(1); |
| 55 |
case TAG_COMPONENT_DATA_3: |
| 56 |
return getComponentDataDescription(2); |
| 57 |
case TAG_COMPONENT_DATA_4: |
| 58 |
return getComponentDataDescription(3); |
| 59 |
case TAG_DATA_PRECISION: |
| 60 |
return getDataPrecisionDescription(); |
| 61 |
case TAG_IMAGE_HEIGHT: |
| 62 |
return getImageHeightDescription(); |
| 63 |
case TAG_IMAGE_WIDTH: |
| 64 |
return getImageWidthDescription(); |
| 65 |
default: |
| 66 |
return super.getDescription(tagType); |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
@Nullable |
| 71 |
public String getImageCompressionTypeDescription() |
| 72 |
{ |
| 73 |
return getIndexedDescription(TAG_COMPRESSION_TYPE, |
| 74 |
"Baseline", |
| 75 |
"Extended sequential, Huffman", |
| 76 |
"Progressive, Huffman", |
| 77 |
"Lossless, Huffman", |
| 78 |
null, |
| 79 |
"Differential sequential, Huffman", |
| 80 |
"Differential progressive, Huffman", |
| 81 |
"Differential lossless, Huffman", |
| 82 |
"Reserved for JPEG extensions", |
| 83 |
"Extended sequential, arithmetic", |
| 84 |
"Progressive, arithmetic", |
| 85 |
"Lossless, arithmetic", |
| 86 |
null, |
| 87 |
"Differential sequential, arithmetic", |
| 88 |
"Differential progressive, arithmetic", |
| 89 |
"Differential lossless, arithmetic"); |
| 90 |
} |
| 91 |
|
| 92 |
@Nullable |
| 93 |
public String getImageWidthDescription() |
| 94 |
{ |
| 95 |
final String value = _directory.getString(TAG_IMAGE_WIDTH); |
| 96 |
if (value==null) |
| 97 |
return null; |
| 98 |
return value + " pixels"; |
| 99 |
} |
| 100 |
|
| 101 |
@Nullable |
| 102 |
public String getImageHeightDescription() |
| 103 |
{ |
| 104 |
final String value = _directory.getString(TAG_IMAGE_HEIGHT); |
| 105 |
if (value==null) |
| 106 |
return null; |
| 107 |
return value + " pixels"; |
| 108 |
} |
| 109 |
|
| 110 |
@Nullable |
| 111 |
public String getDataPrecisionDescription() |
| 112 |
{ |
| 113 |
final String value = _directory.getString(TAG_DATA_PRECISION); |
| 114 |
if (value==null) |
| 115 |
return null; |
| 116 |
return value + " bits"; |
| 117 |
} |
| 118 |
|
| 119 |
@Nullable |
| 120 |
public String getComponentDataDescription(int componentNumber) |
| 121 |
{ |
| 122 |
JpegComponent value = _directory.getComponent(componentNumber); |
| 123 |
|
| 124 |
if (value==null) |
| 125 |
return null; |
| 126 |
|
| 127 |
return value.getComponentName() + " component: " + value; |
| 128 |
} |
| 129 |
} |