| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
package com.drew.metadata.photoshop; |
| 23 |
|
| 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.photoshop.PsdHeaderDirectory.*; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
@SuppressWarnings("WeakerAccess") |
| 34 |
public class PsdHeaderDescriptor extends TagDescriptor<PsdHeaderDirectory> |
| 35 |
{ |
| 36 |
public PsdHeaderDescriptor(@NotNull PsdHeaderDirectory directory) |
| 37 |
{ |
| 38 |
super(directory); |
| 39 |
} |
| 40 |
|
| 41 |
@Override |
| 42 |
public String getDescription(int tagType) |
| 43 |
{ |
| 44 |
switch (tagType) { |
| 45 |
case TAG_CHANNEL_COUNT: |
| 46 |
return getChannelCountDescription(); |
| 47 |
case TAG_BITS_PER_CHANNEL: |
| 48 |
return getBitsPerChannelDescription(); |
| 49 |
case TAG_COLOR_MODE: |
| 50 |
return getColorModeDescription(); |
| 51 |
case TAG_IMAGE_HEIGHT: |
| 52 |
return getImageHeightDescription(); |
| 53 |
case TAG_IMAGE_WIDTH: |
| 54 |
return getImageWidthDescription(); |
| 55 |
default: |
| 56 |
return super.getDescription(tagType); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
@Nullable |
| 61 |
public String getChannelCountDescription() |
| 62 |
{ |
| 63 |
|
| 64 |
Integer value = _directory.getInteger(TAG_CHANNEL_COUNT); |
| 65 |
if (value == null) |
| 66 |
return null; |
| 67 |
return value + " channel" + (value == 1 ? "" : "s"); |
| 68 |
} |
| 69 |
|
| 70 |
@Nullable |
| 71 |
public String getBitsPerChannelDescription() |
| 72 |
{ |
| 73 |
|
| 74 |
Integer value = _directory.getInteger(TAG_BITS_PER_CHANNEL); |
| 75 |
if (value == null) |
| 76 |
return null; |
| 77 |
return value + " bit" + (value == 1 ? "" : "s") + " per channel"; |
| 78 |
} |
| 79 |
|
| 80 |
@Nullable |
| 81 |
public String getColorModeDescription() |
| 82 |
{ |
| 83 |
return getIndexedDescription(TAG_COLOR_MODE, |
| 84 |
"Bitmap", |
| 85 |
"Grayscale", |
| 86 |
"Indexed", |
| 87 |
"RGB", |
| 88 |
"CMYK", |
| 89 |
null, |
| 90 |
null, |
| 91 |
"Multichannel", |
| 92 |
"Duotone", |
| 93 |
"Lab"); |
| 94 |
} |
| 95 |
|
| 96 |
@Nullable |
| 97 |
public String getImageHeightDescription() |
| 98 |
{ |
| 99 |
Integer value = _directory.getInteger(TAG_IMAGE_HEIGHT); |
| 100 |
if (value == null) |
| 101 |
return null; |
| 102 |
return value + " pixel" + (value == 1 ? "" : "s"); |
| 103 |
} |
| 104 |
|
| 105 |
@Nullable |
| 106 |
public String getImageWidthDescription() |
| 107 |
{ |
| 108 |
try { |
| 109 |
Integer value = _directory.getInteger(TAG_IMAGE_WIDTH); |
| 110 |
if (value == null) |
| 111 |
return null; |
| 112 |
return value + " pixel" + (value == 1 ? "" : "s"); |
| 113 |
} catch (Exception e) { |
| 114 |
return null; |
| 115 |
} |
| 116 |
} |
| 117 |
} |