    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *      http://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017package org.apache.commons.imaging.formats.tiff.constants;
    018
    019import java.util.Arrays;
    020import java.util.Collections;
    021import java.util.List;
    022
    023import org.apache.commons.imaging.common.BinaryConstant;
    024import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo;
    025import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoByte;
    026import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoBytes;
    027import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoFloat;
    028import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoLong;
    029import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoUndefineds;
    030
    031/**
    032 * Microsoft's HDP/WDP file format.
    033 */
    034public final class MicrosoftHdPhotoTagConstants {
    035
    036    /*
    037     * The byte order for this GUID field is as follows:
    038     * Data1 (int), Data2 (short), Data3 (short) are little-endian,
    039     * Data4 (char[8]) is endian-independent.
    040     */
    041    public static final TagInfoBytes EXIF_TAG_PIXEL_FORMAT = new TagInfoBytes(
    042            "PixelFormat", 0xbc01, 16,
    043            TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
    044    public static final BinaryConstant PIXEL_FORMAT_VALUE_BLACK_AND_WHITE =
    045            createMicrosoftHdPhotoGuidEndingWith((byte) 0x05);
    046    public static final BinaryConstant PIXEL_FORMAT_VALUE_8_BIT_GRAY =
    047            createMicrosoftHdPhotoGuidEndingWith((byte) 0x08);
    048    public static final BinaryConstant PIXEL_FORMAT_VALUE_16_BIT_BGR555 =
    049            createMicrosoftHdPhotoGuidEndingWith((byte) 0x9);
    050    public static final BinaryConstant PIXEL_FORMAT_VALUE_16_BIT_BGR565 =
    051            createMicrosoftHdPhotoGuidEndingWith((byte) 0xa);
    052    public static final BinaryConstant PIXEL_FORMAT_VALUE_16_BIT_GRAY =
    053            createMicrosoftHdPhotoGuidEndingWith((byte) 0xb);
    054    public static final BinaryConstant PIXEL_FORMAT_VALUE_24_BIT_BGR =
    055            createMicrosoftHdPhotoGuidEndingWith((byte) 0xc);
    056    public static final BinaryConstant PIXEL_FORMAT_VALUE_24_BIT_RGB =
    057            createMicrosoftHdPhotoGuidEndingWith((byte) 0xd);
    058    public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_BGR =
    059            createMicrosoftHdPhotoGuidEndingWith((byte) 0xe);
    060    public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_BGRA =
    061            createMicrosoftHdPhotoGuidEndingWith((byte) 0xf);
    062    public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_PBGRA =
    063            createMicrosoftHdPhotoGuidEndingWith((byte) 0x10);
    064    public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_GRAY_FLOAT =
    065            createMicrosoftHdPhotoGuidEndingWith((byte) 0x11);
    066    public static final BinaryConstant PIXEL_FORMAT_VALUE_48_BIT_RGB_FIXED_POINT =
    067            createMicrosoftHdPhotoGuidEndingWith((byte) 0x12);
    068    public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_BGR101010 =
    069            createMicrosoftHdPhotoGuidEndingWith((byte) 0x13);
    070    public static final BinaryConstant PIXEL_FORMAT_VALUE_48_BIT_RGB =
    071            createMicrosoftHdPhotoGuidEndingWith((byte) 0x15);
    072    public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_RGBA =
    073            createMicrosoftHdPhotoGuidEndingWith((byte) 0x16);
    074    public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_PRGBA =
    075            createMicrosoftHdPhotoGuidEndingWith((byte) 0x17);
    076    public static final BinaryConstant PIXEL_FORMAT_VALUE_96_BIT_RGB_FIXED_POINT =
    077            createMicrosoftHdPhotoGuidEndingWith((byte) 0x18);
    078    public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_RGBA_FLOAT =
    079            createMicrosoftHdPhotoGuidEndingWith((byte) 0x19);
    080    public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_PRGBA_FLOAT =
    081            createMicrosoftHdPhotoGuidEndingWith((byte) 0x1a);
    082    public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_RGB_FLOAT =
    083            createMicrosoftHdPhotoGuidEndingWith((byte) 0x1b);
    084    public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_CMYK =
    085            createMicrosoftHdPhotoGuidEndingWith((byte) 0x1c);
    086    public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_RGBA_FIXED_POINT =
    087            createMicrosoftHdPhotoGuidEndingWith((byte) 0x1d);
    088    public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_RGBA_FIXED_POINT =
    089            createMicrosoftHdPhotoGuidEndingWith((byte) 0x1e);
    090    public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_CMYK =
    091            createMicrosoftHdPhotoGuidEndingWith((byte) 0x1f);
    092    public static final BinaryConstant PIXEL_FORMAT_VALUE_24_BIT_3_CHANNELS =
    093            createMicrosoftHdPhotoGuidEndingWith((byte) 0x20);
    094    public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_4_CHANNELS =
    095            createMicrosoftHdPhotoGuidEndingWith((byte) 0x21);
    096    public static final BinaryConstant PIXEL_FORMAT_VALUE_40_BIT_5_CHANNELS =
    097            createMicrosoftHdPhotoGuidEndingWith((byte) 0x22);
    098    public static final BinaryConstant PIXEL_FORMAT_VALUE_48_BIT_6_CHANNELS =
    099            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}