View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.imaging.formats.tiff.constants;
18  
19  import java.util.Arrays;
20  import java.util.Collections;
21  import java.util.List;
22  
23  import org.apache.commons.imaging.common.BinaryConstant;
24  import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo;
25  import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoByte;
26  import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoBytes;
27  import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoFloat;
28  import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoLong;
29  import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoUndefineds;
30  
31  /**
32   * Microsoft's HDP/WDP file format. 
33   */
34  public final class MicrosoftHdPhotoTagConstants {
35  
36      /*
37       * The byte order for this GUID field is as follows:
38       * Data1 (int), Data2 (short), Data3 (short) are little-endian,
39       * Data4 (char[8]) is endian-independent.
40       */
41      public static final TagInfoBytes EXIF_TAG_PIXEL_FORMAT = new TagInfoBytes(
42              "PixelFormat", 0xbc01, 16,
43              TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
44      public static final BinaryConstant PIXEL_FORMAT_VALUE_BLACK_AND_WHITE =
45              createMicrosoftHdPhotoGuidEndingWith((byte) 0x05);
46      public static final BinaryConstant PIXEL_FORMAT_VALUE_8_BIT_GRAY =
47              createMicrosoftHdPhotoGuidEndingWith((byte) 0x08);
48      public static final BinaryConstant PIXEL_FORMAT_VALUE_16_BIT_BGR555 =
49              createMicrosoftHdPhotoGuidEndingWith((byte) 0x9);
50      public static final BinaryConstant PIXEL_FORMAT_VALUE_16_BIT_BGR565 =
51              createMicrosoftHdPhotoGuidEndingWith((byte) 0xa);
52      public static final BinaryConstant PIXEL_FORMAT_VALUE_16_BIT_GRAY =
53              createMicrosoftHdPhotoGuidEndingWith((byte) 0xb);
54      public static final BinaryConstant PIXEL_FORMAT_VALUE_24_BIT_BGR =
55              createMicrosoftHdPhotoGuidEndingWith((byte) 0xc);
56      public static final BinaryConstant PIXEL_FORMAT_VALUE_24_BIT_RGB =
57              createMicrosoftHdPhotoGuidEndingWith((byte) 0xd);
58      public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_BGR =
59              createMicrosoftHdPhotoGuidEndingWith((byte) 0xe);
60      public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_BGRA =
61              createMicrosoftHdPhotoGuidEndingWith((byte) 0xf);
62      public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_PBGRA =
63              createMicrosoftHdPhotoGuidEndingWith((byte) 0x10);
64      public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_GRAY_FLOAT =
65              createMicrosoftHdPhotoGuidEndingWith((byte) 0x11);
66      public static final BinaryConstant PIXEL_FORMAT_VALUE_48_BIT_RGB_FIXED_POINT =
67              createMicrosoftHdPhotoGuidEndingWith((byte) 0x12);
68      public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_BGR101010 =
69              createMicrosoftHdPhotoGuidEndingWith((byte) 0x13);
70      public static final BinaryConstant PIXEL_FORMAT_VALUE_48_BIT_RGB =
71              createMicrosoftHdPhotoGuidEndingWith((byte) 0x15);
72      public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_RGBA =
73              createMicrosoftHdPhotoGuidEndingWith((byte) 0x16);
74      public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_PRGBA =
75              createMicrosoftHdPhotoGuidEndingWith((byte) 0x17);
76      public static final BinaryConstant PIXEL_FORMAT_VALUE_96_BIT_RGB_FIXED_POINT =
77              createMicrosoftHdPhotoGuidEndingWith((byte) 0x18);
78      public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_RGBA_FLOAT =
79              createMicrosoftHdPhotoGuidEndingWith((byte) 0x19);
80      public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_PRGBA_FLOAT =
81              createMicrosoftHdPhotoGuidEndingWith((byte) 0x1a);
82      public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_RGB_FLOAT =
83              createMicrosoftHdPhotoGuidEndingWith((byte) 0x1b);
84      public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_CMYK =
85              createMicrosoftHdPhotoGuidEndingWith((byte) 0x1c);
86      public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_RGBA_FIXED_POINT =
87              createMicrosoftHdPhotoGuidEndingWith((byte) 0x1d);
88      public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_RGBA_FIXED_POINT =
89              createMicrosoftHdPhotoGuidEndingWith((byte) 0x1e);
90      public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_CMYK =
91              createMicrosoftHdPhotoGuidEndingWith((byte) 0x1f);
92      public static final BinaryConstant PIXEL_FORMAT_VALUE_24_BIT_3_CHANNELS =
93              createMicrosoftHdPhotoGuidEndingWith((byte) 0x20);
94      public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_4_CHANNELS =
95              createMicrosoftHdPhotoGuidEndingWith((byte) 0x21);
96      public static final BinaryConstant PIXEL_FORMAT_VALUE_40_BIT_5_CHANNELS =
97              createMicrosoftHdPhotoGuidEndingWith((byte) 0x22);
98      public static final BinaryConstant PIXEL_FORMAT_VALUE_48_BIT_6_CHANNELS =
99              createMicrosoftHdPhotoGuidEndingWith((byte) 0x23);
100     public static final BinaryConstant PIXEL_FORMAT_VALUE_56_BIT_7_CHANNELS =
101             createMicrosoftHdPhotoGuidEndingWith((byte) 0x24);
102     public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_8_CHANNELS =
103             createMicrosoftHdPhotoGuidEndingWith((byte) 0x25);
104     public static final BinaryConstant PIXEL_FORMAT_VALUE_48_BIT_3_CHANNELS =
105             createMicrosoftHdPhotoGuidEndingWith((byte) 0x26);
106     public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_4_CHANNELS =
107             createMicrosoftHdPhotoGuidEndingWith((byte) 0x27);
108     public static final BinaryConstant PIXEL_FORMAT_VALUE_80_BIT_5_CHANNELS =
109             createMicrosoftHdPhotoGuidEndingWith((byte) 0x28);
110     public static final BinaryConstant PIXEL_FORMAT_VALUE_96_BIT_6_CHANNELS =
111             createMicrosoftHdPhotoGuidEndingWith((byte) 0x29);
112     public static final BinaryConstant PIXEL_FORMAT_VALUE_112_BIT_7_CHANNELS =
113             createMicrosoftHdPhotoGuidEndingWith((byte) 0x2a);
114     public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_8_CHANNELS =
115             createMicrosoftHdPhotoGuidEndingWith((byte) 0x2b);
116     public static final BinaryConstant PIXEL_FORMAT_VALUE_40_BIT_CMYK_ALPHA =
117             createMicrosoftHdPhotoGuidEndingWith((byte) 0x2c);
118     public static final BinaryConstant PIXEL_FORMAT_VALUE_80_BIT_CMYK_ALPHA =
119             createMicrosoftHdPhotoGuidEndingWith((byte) 0x2d);
120     public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_3_CHANNELS_ALPHA =
121             createMicrosoftHdPhotoGuidEndingWith((byte) 0x2e);
122     public static final BinaryConstant PIXEL_FORMAT_VALUE_40_BIT_4_CHANNELS_ALPHA =
123             createMicrosoftHdPhotoGuidEndingWith((byte) 0x2f);
124     public static final BinaryConstant PIXEL_FORMAT_VALUE_48_BIT_5_CHANNELS_ALPHA =
125             createMicrosoftHdPhotoGuidEndingWith((byte) 0x30);
126     public static final BinaryConstant PIXEL_FORMAT_VALUE_56_BIT_6_CHANNELS_ALPHA =
127             createMicrosoftHdPhotoGuidEndingWith((byte) 0x31);
128     public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_7_CHANNELS_ALPHA =
129             createMicrosoftHdPhotoGuidEndingWith((byte) 0x32);
130     public static final BinaryConstant PIXEL_FORMAT_VALUE_72_BIT_8_CHANNELS_ALPHA =
131             createMicrosoftHdPhotoGuidEndingWith((byte) 0x33);
132     public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_3_CHANNELS_ALPHA =
133             createMicrosoftHdPhotoGuidEndingWith((byte) 0x34);
134     public static final BinaryConstant PIXEL_FORMAT_VALUE_80_BIT_4_CHANNELS_ALPHA =
135             createMicrosoftHdPhotoGuidEndingWith((byte) 0x35);
136     public static final BinaryConstant PIXEL_FORMAT_VALUE_96_BIT_5_CHANNELS_ALPHA =
137             createMicrosoftHdPhotoGuidEndingWith((byte) 0x36);
138     public static final BinaryConstant PIXEL_FORMAT_VALUE_112_BIT_6_CHANNELS_ALPHA =
139             createMicrosoftHdPhotoGuidEndingWith((byte) 0x37);
140     public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_7_CHANNELS_ALPHA =
141             createMicrosoftHdPhotoGuidEndingWith((byte) 0x38);
142     public static final BinaryConstant PIXEL_FORMAT_VALUE_144_BIT_8_CHANNELS_ALPHA =
143             createMicrosoftHdPhotoGuidEndingWith((byte) 0x39);
144     public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_RGBA_HALF =
145             createMicrosoftHdPhotoGuidEndingWith((byte) 0x3a);
146     public static final BinaryConstant PIXEL_FORMAT_VALUE_48_BIT_RGB_HALF =
147             createMicrosoftHdPhotoGuidEndingWith((byte) 0x3b);
148     public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_RGBE =
149             createMicrosoftHdPhotoGuidEndingWith((byte) 0x3d);
150     public static final BinaryConstant PIXEL_FORMAT_VALUE_16_BIT_GRAY_HALF =
151             createMicrosoftHdPhotoGuidEndingWith((byte) 0x3e);
152     public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_GRAY_FIXED_POINT =
153             createMicrosoftHdPhotoGuidEndingWith((byte) 0x3f);
154 
155     public static final TagInfoLong EXIF_TAG_TRANSFOMATION = new TagInfoLong(
156             "Transfomation", 0xbc02,
157             TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
158     public static final int TRANSFOMATION_VALUE_HORIZONTAL_NORMAL = 0;
159     public static final int TRANSFOMATION_VALUE_MIRROR_VERTICAL = 1;
160     public static final int TRANSFOMATION_VALUE_MIRROR_HORIZONTAL = 2;
161     public static final int TRANSFOMATION_VALUE_ROTATE_180 = 3;
162     public static final int TRANSFOMATION_VALUE_ROTATE_90_CW = 4;
163     public static final int TRANSFOMATION_VALUE_MIRROR_HORIZONTAL_AND_ROTATE_90_CW = 5;
164     public static final int TRANSFOMATION_VALUE_MIRROR_HORIZONTAL_AND_ROTATE_270_CW = 6;
165     public static final int TRANSFOMATION_VALUE_ROTATE_270_CW = 7;
166     
167     public static final TagInfoLong EXIF_TAG_UNCOMPRESSED = new TagInfoLong(
168             "Uncompressed", 0xbc03,
169             TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
170     public static final int UNCOMPRESSED_VALUE_NO = 0;
171     public static final int UNCOMPRESSED_VALUE_YES = 1;
172 
173     public static final TagInfoLong EXIF_TAG_IMAGE_TYPE = new TagInfoLong(
174             "ImageType", 0xbc04,
175             TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
176 
177     public static final TagInfoLong EXIF_TAG_IMAGE_WIDTH = new TagInfoLong(
178             "ImageWidth", 0xbc80,
179             TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
180     
181     public static final TagInfoLong EXIF_TAG_IMAGE_HEIGHT = new TagInfoLong(
182             "ImageHeight", 0xbc81,
183             TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
184     
185     public static final TagInfoFloat EXIF_TAG_WIDTH_RESOLUTION = new TagInfoFloat(
186             "WidthResolution", 0xbc82,
187             TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
188     
189     public static final TagInfoFloat EXIF_TAG_HEIGHT_RESOLUTION = new TagInfoFloat(
190             "HeightResolution", 0xbc83,
191             TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
192     
193     // FIXME: might be an offset?
194     public static final TagInfoLong EXIF_TAG_IMAGE_OFFSET = new TagInfoLong(
195             "ImageOffset", 0xbcc0,
196             TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
197     
198     public static final TagInfoLong EXIF_TAG_IMAGE_BYTE_COUNT = new TagInfoLong(
199             "ImageByteCount", 0xbcc1,
200             TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
201     
202     // FIXME: might be an offset?
203     public static final TagInfoLong EXIF_TAG_ALPHA_OFFSET = new TagInfoLong(
204             "AlphaOffset", 0xbcc2,
205             TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
206     
207     public static final TagInfoLong EXIF_TAG_ALPHA_BYTE_COUNT = new TagInfoLong(
208             "AlphaByteCount", 0xbcc3,
209             TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
210 
211     public static final TagInfoByte EXIF_TAG_IMAGE_DATA_DISCARD = new TagInfoByte(
212             "ImageDataDiscard", 0xbcc4,
213             TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
214     public static final int IMAGE_DATA_DISCARD_VALUE_FULL_RESOLUTION = 0;
215     public static final int IMAGE_DATA_DISCARD_VALUE_FLEXBITS_DISCARDED = 1;
216     public static final int IMAGE_DATA_DISCARD_VALUE_HIGH_PASS_FREQUENCY_DATA_DISCARDED = 2;
217     public static final int IMAGE_DATA_DISCARD_VALUE_HIGHPASS_AND_LOW_PASS_FREQUENCY_DATA_DISCARDED = 3;
218 
219     public static final TagInfoByte EXIF_TAG_ALPHA_DATA_DISCARD = new TagInfoByte(
220             "AlphaDataDiscard", 0xbcc5,
221             TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
222     public static final int ALPHA_DATA_DISCARD_VALUE_FULL_RESOLUTION = 0;
223     public static final int ALPHA_DATA_DISCARD_VALUE_FLEXBITS_DISCARDED = 1;
224     public static final int ALPHA_DATA_DISCARD_VALUE_HIGH_PASS_FREQUENCY_DATA_DISCARDED = 2;
225     public static final int ALPHA_DATA_DISCARD_VALUE_HIGHPASS_AND_LOW_PASS_FREQUENCY_DATA_DISCARDED = 3;
226 
227     public static final TagInfoUndefineds EXIF_TAG_PADDING = new TagInfoUndefineds(
228             "Padding", 0xea1c, -1,
229             TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
230     
231     public static final List<TagInfo> ALL_MICROSOFT_HD_PHOTO_TAGS =
232             Collections.unmodifiableList(Arrays.asList(
233                     EXIF_TAG_PIXEL_FORMAT,
234                     EXIF_TAG_TRANSFOMATION,
235                     EXIF_TAG_UNCOMPRESSED,
236                     EXIF_TAG_IMAGE_TYPE,
237                     EXIF_TAG_IMAGE_WIDTH,
238                     EXIF_TAG_IMAGE_HEIGHT,
239                     EXIF_TAG_WIDTH_RESOLUTION,
240                     EXIF_TAG_HEIGHT_RESOLUTION,
241                     EXIF_TAG_IMAGE_OFFSET,
242                     EXIF_TAG_IMAGE_BYTE_COUNT,
243                     EXIF_TAG_ALPHA_OFFSET,
244                     EXIF_TAG_ALPHA_BYTE_COUNT,
245                     EXIF_TAG_IMAGE_DATA_DISCARD,
246                     EXIF_TAG_ALPHA_DATA_DISCARD,
247                     EXIF_TAG_PADDING));
248 
249     private static BinaryConstant createMicrosoftHdPhotoGuidEndingWith(final byte end) {
250         return new BinaryConstant(new byte[] { (byte) 0x24, (byte) 0xC3,
251                 (byte) 0xDD, (byte) 0x6F, (byte) 0x03, (byte) 0x4E,
252                 (byte) 0xFE, (byte) 0x4B, (byte) 0xB1, (byte) 0x85,
253                 (byte) 0x3D, (byte) 0x77, (byte) 0x76, (byte) 0x8D,
254                 (byte) 0xC9, end });
255     }
256     
257     private MicrosoftHdPhotoTagConstants() {
258     }
259 }