    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: Data1 (int), Data2 (short), Data3 (short) are little-endian, Data4 (char[8]) is endian-independent.
    038     */
    039    public static final TagInfoBytes EXIF_TAG_PIXEL_FORMAT = new TagInfoBytes("PixelFormat", 0xbc01, 16, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
    040    public static final BinaryConstant PIXEL_FORMAT_VALUE_BLACK_AND_WHITE = createMicrosoftHdPhotoGuidEndingWith((byte) 0x05);
    041    public static final BinaryConstant PIXEL_FORMAT_VALUE_8_BIT_GRAY = createMicrosoftHdPhotoGuidEndingWith((byte) 0x08);
    042    public static final BinaryConstant PIXEL_FORMAT_VALUE_16_BIT_BGR555 = createMicrosoftHdPhotoGuidEndingWith((byte) 0x9);
    043    public static final BinaryConstant PIXEL_FORMAT_VALUE_16_BIT_BGR565 = createMicrosoftHdPhotoGuidEndingWith((byte) 0xa);
    044    public static final BinaryConstant PIXEL_FORMAT_VALUE_16_BIT_GRAY = createMicrosoftHdPhotoGuidEndingWith((byte) 0xb);
    045    public static final BinaryConstant PIXEL_FORMAT_VALUE_24_BIT_BGR = createMicrosoftHdPhotoGuidEndingWith((byte) 0xc);
    046    public static final BinaryConstant PIXEL_FORMAT_VALUE_24_BIT_RGB = createMicrosoftHdPhotoGuidEndingWith((byte) 0xd);
    047    public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_BGR = createMicrosoftHdPhotoGuidEndingWith((byte) 0xe);
    048    public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_BGRA = createMicrosoftHdPhotoGuidEndingWith((byte) 0xf);
    049    public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_PBGRA = createMicrosoftHdPhotoGuidEndingWith((byte) 0x10);
    050    public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_GRAY_FLOAT = createMicrosoftHdPhotoGuidEndingWith((byte) 0x11);
    051    public static final BinaryConstant PIXEL_FORMAT_VALUE_48_BIT_RGB_FIXED_POINT = createMicrosoftHdPhotoGuidEndingWith((byte) 0x12);
    052    public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_BGR101010 = createMicrosoftHdPhotoGuidEndingWith((byte) 0x13);
    053    public static final BinaryConstant PIXEL_FORMAT_VALUE_48_BIT_RGB = createMicrosoftHdPhotoGuidEndingWith((byte) 0x15);
    054    public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_RGBA = createMicrosoftHdPhotoGuidEndingWith((byte) 0x16);
    055    public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_PRGBA = createMicrosoftHdPhotoGuidEndingWith((byte) 0x17);
    056    public static final BinaryConstant PIXEL_FORMAT_VALUE_96_BIT_RGB_FIXED_POINT = createMicrosoftHdPhotoGuidEndingWith((byte) 0x18);
    057    public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_RGBA_FLOAT = createMicrosoftHdPhotoGuidEndingWith((byte) 0x19);
    058    public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_PRGBA_FLOAT = createMicrosoftHdPhotoGuidEndingWith((byte) 0x1a);
    059    public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_RGB_FLOAT = createMicrosoftHdPhotoGuidEndingWith((byte) 0x1b);
    060    public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_CMYK = createMicrosoftHdPhotoGuidEndingWith((byte) 0x1c);
    061    public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_RGBA_FIXED_POINT = createMicrosoftHdPhotoGuidEndingWith((byte) 0x1d);
    062    public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_RGBA_FIXED_POINT = createMicrosoftHdPhotoGuidEndingWith((byte) 0x1e);
    063    public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_CMYK = createMicrosoftHdPhotoGuidEndingWith((byte) 0x1f);
    064    public static final BinaryConstant PIXEL_FORMAT_VALUE_24_BIT_3_CHANNELS = createMicrosoftHdPhotoGuidEndingWith((byte) 0x20);
    065    public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_4_CHANNELS = createMicrosoftHdPhotoGuidEndingWith((byte) 0x21);
    066    public static final BinaryConstant PIXEL_FORMAT_VALUE_40_BIT_5_CHANNELS = createMicrosoftHdPhotoGuidEndingWith((byte) 0x22);
    067    public static final BinaryConstant PIXEL_FORMAT_VALUE_48_BIT_6_CHANNELS = createMicrosoftHdPhotoGuidEndingWith((byte) 0x23);
    068    public static final BinaryConstant PIXEL_FORMAT_VALUE_56_BIT_7_CHANNELS = createMicrosoftHdPhotoGuidEndingWith((byte) 0x24);
    069    public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_8_CHANNELS = createMicrosoftHdPhotoGuidEndingWith((byte) 0x25);
    070    public static final BinaryConstant PIXEL_FORMAT_VALUE_48_BIT_3_CHANNELS = createMicrosoftHdPhotoGuidEndingWith((byte) 0x26);
    071    public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_4_CHANNELS = createMicrosoftHdPhotoGuidEndingWith((byte) 0x27);
    072    public static final BinaryConstant PIXEL_FORMAT_VALUE_80_BIT_5_CHANNELS = createMicrosoftHdPhotoGuidEndingWith((byte) 0x28);
    073    public static final BinaryConstant PIXEL_FORMAT_VALUE_96_BIT_6_CHANNELS = createMicrosoftHdPhotoGuidEndingWith((byte) 0x29);
    074    public static final BinaryConstant PIXEL_FORMAT_VALUE_112_BIT_7_CHANNELS = createMicrosoftHdPhotoGuidEndingWith((byte) 0x2a);
    075    public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_8_CHANNELS = createMicrosoftHdPhotoGuidEndingWith((byte) 0x2b);
    076    public static final BinaryConstant PIXEL_FORMAT_VALUE_40_BIT_CMYK_ALPHA = createMicrosoftHdPhotoGuidEndingWith((byte) 0x2c);
    077    public static final BinaryConstant PIXEL_FORMAT_VALUE_80_BIT_CMYK_ALPHA = createMicrosoftHdPhotoGuidEndingWith((byte) 0x2d);
    078    public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_3_CHANNELS_ALPHA = createMicrosoftHdPhotoGuidEndingWith((byte) 0x2e);
    079    public static final BinaryConstant PIXEL_FORMAT_VALUE_40_BIT_4_CHANNELS_ALPHA = createMicrosoftHdPhotoGuidEndingWith((byte) 0x2f);
    080    public static final BinaryConstant PIXEL_FORMAT_VALUE_48_BIT_5_CHANNELS_ALPHA = createMicrosoftHdPhotoGuidEndingWith((byte) 0x30);
    081    public static final BinaryConstant PIXEL_FORMAT_VALUE_56_BIT_6_CHANNELS_ALPHA = createMicrosoftHdPhotoGuidEndingWith((byte) 0x31);
    082    public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_7_CHANNELS_ALPHA = createMicrosoftHdPhotoGuidEndingWith((byte) 0x32);
    083    public static final BinaryConstant PIXEL_FORMAT_VALUE_72_BIT_8_CHANNELS_ALPHA = createMicrosoftHdPhotoGuidEndingWith((byte) 0x33);
    084    public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_3_CHANNELS_ALPHA = createMicrosoftHdPhotoGuidEndingWith((byte) 0x34);
    085    public static final BinaryConstant PIXEL_FORMAT_VALUE_80_BIT_4_CHANNELS_ALPHA = createMicrosoftHdPhotoGuidEndingWith((byte) 0x35);
    086    public static final BinaryConstant PIXEL_FORMAT_VALUE_96_BIT_5_CHANNELS_ALPHA = createMicrosoftHdPhotoGuidEndingWith((byte) 0x36);
    087    public static final BinaryConstant PIXEL_FORMAT_VALUE_112_BIT_6_CHANNELS_ALPHA = createMicrosoftHdPhotoGuidEndingWith((byte) 0x37);
    088    public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_7_CHANNELS_ALPHA = createMicrosoftHdPhotoGuidEndingWith((byte) 0x38);
    089    public static final BinaryConstant PIXEL_FORMAT_VALUE_144_BIT_8_CHANNELS_ALPHA = createMicrosoftHdPhotoGuidEndingWith((byte) 0x39);
    090    public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_RGBA_HALF = createMicrosoftHdPhotoGuidEndingWith((byte) 0x3a);
    091    public static final BinaryConstant PIXEL_FORMAT_VALUE_48_BIT_RGB_HALF = createMicrosoftHdPhotoGuidEndingWith((byte) 0x3b);
    092    public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_RGBE = createMicrosoftHdPhotoGuidEndingWith((byte) 0x3d);
    093    public static final BinaryConstant PIXEL_FORMAT_VALUE_16_BIT_GRAY_HALF = createMicrosoftHdPhotoGuidEndingWith((byte) 0x3e);
    094    public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_GRAY_FIXED_POINT = createMicrosoftHdPhotoGuidEndingWith((byte) 0x3f);
    095
    096    public static final TagInfoLong EXIF_TAG_TRANSFORMATION = new TagInfoLong("Transformation", 0xbc02, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
    097    public static final int TRANSFORMATION_VALUE_HORIZONTAL_NORMAL = 0;
    098    public static final int TRANSFORMATION_VALUE_MIRROR_VERTICAL = 1;
    099    public static final int TRANSFORMATION_VALUE_MIRROR_HORIZONTAL = 2;
    100    public static final int TRANSFORMATION_VALUE_ROTATE_180 = 3;
    101    public static final int TRANSFORMATION_VALUE_ROTATE_90_CW = 4;
    102    public static final int TRANSFORMATION_VALUE_MIRROR_HORIZONTAL_AND_ROTATE_90_CW = 5;
    103    public static final int TRANSFORMATION_VALUE_MIRROR_HORIZONTAL_AND_ROTATE_270_CW = 6;
    104    public static final int TRANSFORMATION_VALUE_ROTATE_270_CW = 7;
    105
    106    public static final TagInfoLong EXIF_TAG_UNCOMPRESSED = new TagInfoLong("Uncompressed", 0xbc03, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
    107    public static final int UNCOMPRESSED_VALUE_NO = 0;
    108    public static final int UNCOMPRESSED_VALUE_YES = 1;
    109
    110    public static final TagInfoLong EXIF_TAG_IMAGE_TYPE = new TagInfoLong("ImageType", 0xbc04, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
    111
    112    public static final TagInfoLong EXIF_TAG_IMAGE_WIDTH = new TagInfoLong("ImageWidth", 0xbc80, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
    113
    114    public static final TagInfoLong EXIF_TAG_IMAGE_HEIGHT = new TagInfoLong("ImageHeight", 0xbc81, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
    115
    116    public static final TagInfoFloat EXIF_TAG_WIDTH_RESOLUTION = new TagInfoFloat("WidthResolution", 0xbc82, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
    117
    118    public static final TagInfoFloat EXIF_TAG_HEIGHT_RESOLUTION = new TagInfoFloat("HeightResolution", 0xbc83, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
    119
    120    // FIXME: might be an offset?
    121    public static final TagInfoLong EXIF_TAG_IMAGE_OFFSET = new TagInfoLong("ImageOffset", 0xbcc0, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
    122
    123    public static final TagInfoLong EXIF_TAG_IMAGE_BYTE_COUNT = new TagInfoLong("ImageByteCount", 0xbcc1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
    124
    125    // FIXME: might be an offset?
    126    public static final TagInfoLong EXIF_TAG_ALPHA_OFFSET = new TagInfoLong("AlphaOffset", 0xbcc2, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
    127
    128    public static final TagInfoLong EXIF_TAG_ALPHA_BYTE_COUNT = new TagInfoLong("AlphaByteCount", 0xbcc3, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
    129
    130    public static final TagInfoByte EXIF_TAG_IMAGE_DATA_DISCARD = new TagInfoByte("ImageDataDiscard", 0xbcc4, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
    131    public static final int IMAGE_DATA_DISCARD_VALUE_FULL_RESOLUTION = 0;
    132    public static final int IMAGE_DATA_DISCARD_VALUE_FLEXBITS_DISCARDED = 1;
    133    public static final int IMAGE_DATA_DISCARD_VALUE_HIGH_PASS_FREQUENCY_DATA_DISCARDED = 2;
    134    public static final int IMAGE_DATA_DISCARD_VALUE_HIGHPASS_AND_LOW_PASS_FREQUENCY_DATA_DISCARDED = 3;
    135
    136    public static final TagInfoByte EXIF_TAG_ALPHA_DATA_DISCARD = new TagInfoByte("AlphaDataDiscard", 0xbcc5, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
    137    public static final int ALPHA_DATA_DISCARD_VALUE_FULL_RESOLUTION = 0;
    138    public static final int ALPHA_DATA_DISCARD_VALUE_FLEXBITS_DISCARDED = 1;
    139    public static final int ALPHA_DATA_DISCARD_VALUE_HIGH_PASS_FREQUENCY_DATA_DISCARDED = 2;
    140    public static final int ALPHA_DATA_DISCARD_VALUE_HIGHPASS_AND_LOW_PASS_FREQUENCY_DATA_DISCARDED = 3;
    141
    142    public static final TagInfoUndefineds EXIF_TAG_PADDING = new TagInfoUndefineds("Padding", 0xea1c, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
    143
    144    public static final List<TagInfo> ALL_MICROSOFT_HD_PHOTO_TAGS = Collections
    145            .unmodifiableList(Arrays.asList(EXIF_TAG_PIXEL_FORMAT, EXIF_TAG_TRANSFORMATION, EXIF_TAG_UNCOMPRESSED, EXIF_TAG_IMAGE_TYPE, EXIF_TAG_IMAGE_WIDTH,
    146                    EXIF_TAG_IMAGE_HEIGHT, EXIF_TAG_WIDTH_RESOLUTION, EXIF_TAG_HEIGHT_RESOLUTION, EXIF_TAG_IMAGE_OFFSET, EXIF_TAG_IMAGE_BYTE_COUNT,
    147                    EXIF_TAG_ALPHA_OFFSET, EXIF_TAG_ALPHA_BYTE_COUNT, EXIF_TAG_IMAGE_DATA_DISCARD, EXIF_TAG_ALPHA_DATA_DISCARD, EXIF_TAG_PADDING));
    148
    149    private static BinaryConstant createMicrosoftHdPhotoGuidEndingWith(final byte end) {
    150        return new BinaryConstant(new byte[] { (byte) 0x24, (byte) 0xC3, (byte) 0xDD, (byte) 0x6F, (byte) 0x03, (byte) 0x4E, (byte) 0xFE, (byte) 0x4B,
    151                (byte) 0xB1, (byte) 0x85, (byte) 0x3D, (byte) 0x77, (byte) 0x76, (byte) 0x8D, (byte) 0xC9, end });
    152    }
    153
    154    private MicrosoftHdPhotoTagConstants() {
    155    }
    156}