source: josm/trunk/src/com/drew/imaging/tiff/TiffDataFormat.java@ 10862

Last change on this file since 10862 was 10862, checked in by Don-vip, 8 years ago

update to metadata-extractor 2.9.1

File size: 4.0 KB
Line 
1/*
2 * Copyright 2002-2016 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 */
21package com.drew.imaging.tiff;
22
23import com.drew.lang.annotations.NotNull;
24import com.drew.lang.annotations.Nullable;
25
26/**
27 * An enumeration of data formats used by the TIFF specification.
28 *
29 * @author Drew Noakes https://drewnoakes.com
30 */
31public 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}
Note: See TracBrowser for help on using the repository browser.