| 1 |
/* |
| 2 |
* Copyright 2002-2017 Drew Noakes |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
* you may not use this file except in compliance with the License. |
| 6 |
* You may obtain a copy of the License at |
| 7 |
* |
| 8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
* |
| 10 |
* Unless required by applicable law or agreed to in writing, software |
| 11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
* See the License for the specific language governing permissions and |
| 14 |
* limitations under the License. |
| 15 |
* |
| 16 |
* More information about this project is available at: |
| 17 |
* |
| 18 |
* https://drewnoakes.com/code/exif/ |
| 19 |
* https://github.com/drewnoakes/metadata-extractor |
| 20 |
*/ |
| 21 |
package com.drew.metadata.png; |
| 22 |
|
| 23 |
import com.drew.imaging.png.PngChunkType; |
| 24 |
import com.drew.lang.annotations.NotNull; |
| 25 |
import com.drew.metadata.Directory; |
| 26 |
|
| 27 |
import java.util.HashMap; |
| 28 |
|
| 29 |
/** |
| 30 |
* @author Drew Noakes https://drewnoakes.com |
| 31 |
*/ |
| 32 |
@SuppressWarnings("WeakerAccess") |
| 33 |
public class PngDirectory extends Directory |
| 34 |
{ |
| 35 |
public static final int TAG_IMAGE_WIDTH = 1; |
| 36 |
public static final int TAG_IMAGE_HEIGHT = 2; |
| 37 |
public static final int TAG_BITS_PER_SAMPLE = 3; |
| 38 |
public static final int TAG_COLOR_TYPE = 4; |
| 39 |
public static final int TAG_COMPRESSION_TYPE = 5; |
| 40 |
public static final int TAG_FILTER_METHOD = 6; |
| 41 |
public static final int TAG_INTERLACE_METHOD = 7; |
| 42 |
public static final int TAG_PALETTE_SIZE = 8; |
| 43 |
public static final int TAG_PALETTE_HAS_TRANSPARENCY = 9; |
| 44 |
public static final int TAG_SRGB_RENDERING_INTENT = 10; |
| 45 |
public static final int TAG_GAMMA = 11; |
| 46 |
public static final int TAG_ICC_PROFILE_NAME = 12; |
| 47 |
public static final int TAG_TEXTUAL_DATA = 13; |
| 48 |
public static final int TAG_LAST_MODIFICATION_TIME = 14; |
| 49 |
public static final int TAG_BACKGROUND_COLOR = 15; |
| 50 |
|
| 51 |
public static final int TAG_PIXELS_PER_UNIT_X = 16; |
| 52 |
public static final int TAG_PIXELS_PER_UNIT_Y = 17; |
| 53 |
public static final int TAG_UNIT_SPECIFIER = 18; |
| 54 |
|
| 55 |
public static final int TAG_SIGNIFICANT_BITS = 19; |
| 56 |
|
| 57 |
@NotNull |
| 58 |
protected static final HashMap<Integer, String> _tagNameMap = new HashMap<Integer, String>(); |
| 59 |
|
| 60 |
static { |
| 61 |
_tagNameMap.put(TAG_IMAGE_HEIGHT, "Image Height"); |
| 62 |
_tagNameMap.put(TAG_IMAGE_WIDTH, "Image Width"); |
| 63 |
_tagNameMap.put(TAG_BITS_PER_SAMPLE, "Bits Per Sample"); |
| 64 |
_tagNameMap.put(TAG_COLOR_TYPE, "Color Type"); |
| 65 |
_tagNameMap.put(TAG_COMPRESSION_TYPE, "Compression Type"); |
| 66 |
_tagNameMap.put(TAG_FILTER_METHOD, "Filter Method"); |
| 67 |
_tagNameMap.put(TAG_INTERLACE_METHOD, "Interlace Method"); |
| 68 |
_tagNameMap.put(TAG_PALETTE_SIZE, "Palette Size"); |
| 69 |
_tagNameMap.put(TAG_PALETTE_HAS_TRANSPARENCY, "Palette Has Transparency"); |
| 70 |
_tagNameMap.put(TAG_SRGB_RENDERING_INTENT, "sRGB Rendering Intent"); |
| 71 |
_tagNameMap.put(TAG_GAMMA, "Image Gamma"); |
| 72 |
_tagNameMap.put(TAG_ICC_PROFILE_NAME, "ICC Profile Name"); |
| 73 |
_tagNameMap.put(TAG_TEXTUAL_DATA, "Textual Data"); |
| 74 |
_tagNameMap.put(TAG_LAST_MODIFICATION_TIME, "Last Modification Time"); |
| 75 |
_tagNameMap.put(TAG_BACKGROUND_COLOR, "Background Color"); |
| 76 |
_tagNameMap.put(TAG_PIXELS_PER_UNIT_X, "Pixels Per Unit X"); |
| 77 |
_tagNameMap.put(TAG_PIXELS_PER_UNIT_Y, "Pixels Per Unit Y"); |
| 78 |
_tagNameMap.put(TAG_UNIT_SPECIFIER, "Unit Specifier"); |
| 79 |
_tagNameMap.put(TAG_SIGNIFICANT_BITS, "Significant Bits"); |
| 80 |
} |
| 81 |
|
| 82 |
private final PngChunkType _pngChunkType; |
| 83 |
|
| 84 |
public PngDirectory(@NotNull PngChunkType pngChunkType) |
| 85 |
{ |
| 86 |
_pngChunkType = pngChunkType; |
| 87 |
|
| 88 |
this.setDescriptor(new PngDescriptor(this)); |
| 89 |
} |
| 90 |
|
| 91 |
@NotNull |
| 92 |
public PngChunkType getPngChunkType() |
| 93 |
{ |
| 94 |
return _pngChunkType; |
| 95 |
} |
| 96 |
|
| 97 |
@Override |
| 98 |
@NotNull |
| 99 |
public String getName() |
| 100 |
{ |
| 101 |
return "PNG-" + _pngChunkType.getIdentifier(); |
| 102 |
} |
| 103 |
|
| 104 |
@Override |
| 105 |
@NotNull |
| 106 |
protected HashMap<Integer, String> getTagNameMap() |
| 107 |
{ |
| 108 |
return _tagNameMap; |
| 109 |
} |
| 110 |
} |