Operations > OP_HDPHOTOP |
OP_HDPHOTOP: Compress image to HD Photo
The purpose of OP_HDPHOTOP (see opcode specific data structure) is to compress images according to the ISO JPEG XR Image Coding Specification. It can also compress images according to the older Microsoft HD Photo specification. HD Photo (formerly known as Windows Media Photo) was adopted by ISO as a standard compression format in 2009 and was renamed JPEG XR (ISO/IEC 29199-2). It was also given some additional enhancements, e.g. additional image formats, and an improved overlap filter (used in the entropy-transform). JPEG XR is an image compression algorithm and file format that is designed for use with continuous tone images, such as photographs. It provides lossless or lossy compression and supports a wide range of pixel formats, including bilevel, gray, RGB, and CMYK, using up to 16-bit integer representation, or up to 32-bit fixed or floating point representation. JPEG XR also supports several packed bit formats, including 5 or 10bpc RGB and RGBE/Radiance.
The file format used by JPEG XR is based on the TIFF format. Image data is stored in a table of Image File Directory (IFD) tags. A JPEG XR file contains image data, optional alpha channel data, HD Photo metadata, optional XMP metadata, and optional Exif metadata. The image data is stored as a contiguous block of data. The opcode generates the file container and writes it to the Put queue.
OP_HDPHOTOP supports a wide range of pixel formats. The characteristics of the input image may be specified in one of two ways: 1) set the flag F_Bmp in PicParm.Flags and fill in the PicParm.Head fields, or 2) set the flag F_Raw in PicParm.Flags and fill in the u.HDP.Region fields. The following table shows the allowable pixel formats for the input image to be compressed. The table contains the following information:
PixelFormat |
Ch |
BPC |
Bpp |
PixType |
Flags |
biCompression |
24bppRGB |
3 |
8 |
24 |
PT_RGB |
RF_SwapRB |
|
24bppBGR |
3 |
8 |
24 |
PT_RGB |
|
BI_RGB |
32bppBGR |
3 |
8 |
32 |
PT_RGB |
|
|
48bppRGB |
3 |
16 |
48 |
PT_RGB |
RF_SwapRB |
|
48bppRGBFixedPoint |
3 |
16 |
48 |
PT_RGB_MSFIXED |
RF_SwapRB |
|
48bppRGBHalf |
3 |
16 |
48 |
PT_RGB_FLOAT |
RF_SwapRB |
|
96bppRGBFloat (2) |
3 |
32 |
96 |
PT_RGB_FLOAT |
RF_SwapRB |
|
96bppRGBFixedPoint |
3 |
32 |
96 |
PT_RGB_MSFIXED |
RF_SwapRB |
|
128bppRGBFloat |
3(1) |
32 |
128 |
PT_RGB_FLOAT |
RF_SwapRB |
|
16bppRGB555 |
3 |
5 |
16 |
PT_RGB555 |
|
BI_BITFIELDS |
16bppRGB565 |
3 |
5,6,5 |
16 |
PT_RGB565 |
|
BI_BITFIELDS |
32bppRGB101010 |
3 |
10 |
32 |
PT_RGB101010 |
|
BI_BITFIELDS |
32bppRGBE |
3 |
16 |
32 |
PT_RGBE |
|
|
32bppRGBA (2) |
4 |
8 |
32 |
PT_RGBA |
RF_SwapRB |
|
32bppBGRA |
4 |
8 |
32 |
PT_RGBA |
|
BI_RGB |
32bppPBGRA |
4 |
8 |
32 |
PT_PRGBA |
|
|
64bppRGBA |
4 |
16 |
64 |
PT_RGBA |
RF_SwapRB |
|
64bppRGBAFixedPoint |
4 |
16 |
64 |
PT_RGBA_MSFIXED |
RF_SwapRB |
|
64bppRGBFixedPoint |
3(1) |
16 |
64 |
PT_RGB_MSFIXED |
RF_SwapRB |
|
64bppRGBAHalf |
4 |
16 |
64 |
PT_RGBA_FLOAT |
RF_SwapRB |
|
64bppRGBHalf |
3(1) |
16 |
64 |
PT_RGBA_FLOAT |
RF_SwapRB |
|
64bppPRGBA |
4 |
16 |
64 |
PT_PRGBA |
RF_SwapRB |
|
128bppRGBAFixedPoint |
4 |
32 |
128 |
PT_RGBA_MSFIXED |
RF_SwapRB |
|
128bppRGBFixedPoint |
3(1) |
32 |
128 |
PT_RGBA_MSFIXED |
RF_SwapRB |
|
128bppRGBAFloat |
4 |
32 |
128 |
PT_RGBA_FLOAT |
RF_SwapRB |
|
128bppPRGBAFloat |
4 |
32 |
128 |
PT_PRGBA_FLOAT |
RF_SwapRB |
|
8bppGray |
1 |
8 |
8 |
PT_GRAY |
|
BI_RGB |
16bppGray |
1 |
16 |
16 |
PT_GRAY |
|
|
16bppGrayFixedPoint |
1 |
16 |
16 |
PT_GRAY_MSFIXED |
|
|
16bppGrayHalf |
1 |
16 |
16 |
PT_GRAY_FLOAT |
|
|
32bppGrayFixedPoint |
1 |
32 |
32 |
PT_GRAY_MSFIXED |
|
|
32bppGrayFloat |
1 |
32 |
32 |
PT_GRAY_FLOAT |
|
|
BlackWhite |
1 |
1 |
1 |
PT_GRAY |
|
BI_RGB |
32bppCMYK |
4 |
8 |
32 |
PT_CMYK |
|
|
64bppCMYK |
4 |
16 |
64 |
PT_CMYK |
|
|
40bppCMYKAlpha |
5 |
8 |
40 |
PT_CMYKA |
|
|
80bppCMYKAlpha |
5 |
16 |
80 |
PT_CMYKA |
|
|
24bpp3Channels |
3 |
8 |
24 |
PT_N8CHAN |
|
|
32bpp3ChannelsAlpha |
4 |
8 |
32 |
PT_N8CHANA |
|
|
32bpp4Channels |
4 |
8 |
32 |
PT_N8CHAN |
|
|
40bpp4ChannelsAlpha |
5 |
8 |
40 |
PT_N8CHANA |
|
|
40bpp5Channels |
5 |
8 |
40 |
PT_N8CHAN |
|
|
48bpp5ChannelsAlpha |
6 |
8 |
48 |
PT_N8CHANA |
|
|
48bpp6Channels |
6 |
8 |
48 |
PT_N8CHAN |
|
|
56bpp6ChannelsAlpha |
7 |
8 |
56 |
PT_N8CHANA |
|
|
56bpp7Channels |
7 |
8 |
56 |
PT_N8CHAN |
|
|
64bpp7ChannelsAlpha |
8 |
8 |
64 |
PT_N8CHANA |
|
|
64bpp8Channels |
8 |
8 |
64 |
PT_N8CHAN |
|
|
72bpp8ChannelsAlpha |
9 |
8 |
72 |
PT_N8CHANA |
|
|
48bpp3Channels |
3 |
16 |
48 |
PT_N16CHAN |
|
|
64bpp3ChannelsAlpha |
4 |
16 |
64 |
PT_N16CHANA |
|
|
64bpp4Channels |
4 |
16 |
64 |
PT_N16CHAN |
|
|
80bpp4ChannelsAlpha |
5 |
16 |
80 |
PT_N16CHANA |
|
|
80bpp5Channels |
5 |
16 |
80 |
PT_N16CHAN |
|
|
96bpp5ChannelsAlpha |
6 |
16 |
96 |
PT_N16CHANA |
|
|
96bpp6Channels |
6 |
16 |
96 |
PT_N16CHAN |
|
|
112bpp6ChannelsAlpha |
7 |
16 |
112 |
PT_N16CHANA |
|
|
112bpp7Channels |
7 |
16 |
112 |
PT_N16CHAN |
|
|
128bpp7ChannelsAlpha |
8 |
16 |
128 |
PT_N16CHANA |
|
|
128bpp8Channels |
8 |
16 |
128 |
PT_N16CHAN |
|
|
144bpp8ChannelsAlpha |
9 |
16 |
144 |
PT_N16CHANA |
|
|
(1) By default, these are input/output as 3-channels per pixel with no padding. The application may change the u.HDP.Region2.Bpp before REQ_EXEC to optionally specify that the pixel format includes an interleaved 'padding' channel.
(2) These pixel formats are not defined by the JPEG XR standard. They are supported in the opcode to accommodate additional commonly encountered image formats and for compatibility with the older HD Photo. When presented to the opcode, the PixelFormat that is conveyed to the decompressor in the HD Photo/JPEG XR container will be translated to a compliant format.
u.HDP.StripSize will have been set by OP_HDPHOTOP after REQ_INIT is complete. The Get queue must be at least StripSize bytes in length.
For 1bpp, black and white images, if F_Bmp is set, then OP_HDPHOTOP uses the colormap to determine whether a 0 bit is black and a 1 bit is white or the reverse. If F_Raw is set, OP_HDPHOTOP assumes that a 0 bit is black unless the flag RF_WhiteIsZero is set in u.HDP.Region.Flags.
HD Photo accepts the storage of optional descriptive metadata in TIFF compatible tags. The application can use PIC2List P2P_TiffTag packets to supply OP_HDPHOTOP with one or more TIFF tags to be embedded in the output compressed file. The optional tags that are allowed are: DocumentName, ImageDescription, Make, Model, PageName, PageNumber, Software, DateTime, Artist, HostComputer, Copyright, RatingStars, RatingValue, Caption, XMPMetadata, ICCProfile, EXIFMetadata, GPSInfoMetadata, IPTCNAAMetadata, PhotoshopMetadata, and InteroperabilityIFD. See include\pic2file.h and the PIC2List section of Accessing Comments and Other Auxiliary Data in the PICTools and AIMTools Programmer's Guide for more information about PIC2List packets.
The characteristics of the encoded image are controlled by a set of parameters contained in u.HDP. See the description of the HDP structure in this document for a complete description of these parameters.
Pixel format conversions are not supported. The pixel format of the compressed image will be the same as the pixel format of the input image.