Pixel Formats (Part 1: Unsigned Integers)
This is the first installment of what I plan to be an ongoing series of personal technical notes about all things related to Windows Media Photo. We’re starting with the very basics – pixel formats.
Windows Media Photo supports far more pixel formats than any other image file format. In fact, several of the supported pixel formats are brand new, being introduced for the first time with Windows Vista (and WIC or .NET Frameworks 3.0 for down-level support.) Let’s take a closer look at pixel formats and the new capabilities supported by Windows Media Photo.
A Little Background
Historically, color images have been encoded using three unsigned integer values for red, green and blue. Monochrome (or gray scale) images use a single unsigned integer per pixel. Virtually all consumer photography uses 8-bit unsigned integer values, providing 256 unique values for each of the three channels. For more demanding requirements, many applications also support 16-bit unsigned integers, offering 65536 unique values per channel.
256 steps from the darkest value to the lightest value present some significant limitations. In actuality, 256 steps per channel are all that are required to display an image on a monitor. But that assumes that the values correspond to the monitor’s interpretation of color. Since that is rarely the case, transformations between different color spaces are required, losing a certain amount of the already limited precision. The artifacts that come from this loss of precision often shows up as visible bands in smooth, continuous color areas, where there are no longer enough unique values to represent the color range without seeing visible steps between adjacent values. Using 16 bits per channel provides more than sufficient resolution to insure more than 8 bits per channel are always retained through any color space conversion. Of course, twice as much data is required to guarantee this quality.
Using unsigned integers is currently the most common way to encode color information, and Windows Media Photo has rich support for unsigned integer pixel formats in multiple color formats and bit depths.
The Colorless World of Gray Scale
Let’s start with the Gray unsigned integer pixel formats:
|
PixelFormat Name
GUID |
Ch |
BPC |
BPP |
Num |
Color |
A |
B |
|
WICPixelFormat8bppGray
6fddc324-4e03-4bfe-b1853d77768dc908 |
1 |
8 |
8 |
UINT |
Gray |
|
ü |
|
WICPixelFormat16bppGray
6fddc324-4e03-4bfe-b1853d77768dc90b |
1 |
16 |
16 |
UINT |
Gray |
|
ü |
|
WICPixelFormatBlackWhite
6fddc324-4e03-4bfe-b1853d77768dc905 |
1 |
1 |
1 |
UINT |
Gray |
|
|
If you’ve already taken a look at the Windows Media Photo Feature Specification, then you’re familiar with these pixel format tables. But, let’s recap the information summarized in the table.
Name This is the descriptive name that we use to refer to the pixel format. This is frequently abbreviated by dropping the WICPixelFormat prefix.
GUID The 128-bit Globally Unique Identifier for the pixel format.
Ch The number of channels.
BPC Bits per channel.
BPP Bits per pixel. This is typically the number of channels multiplied by the number of bits per channel. However, some pixel formats contain unused information in each pixel value to align pixel values to a specific boundary.
Num The numerical format.
Color The color format.
A Indicates that the pixel format contains an alpha channel. This is included in the channel count.
B Indicates that this pixel format is one of the BASIC pixel formats that is required to be supported by all Windows Media Photo decoders.
The unsigned integer Gray pixel formats are pretty straightforward. The two Basic formats are either 8bpc or 16bpc. These correspond to the most commonly used monochrome pixel formats in use today. In addition, the third pixel format uses a single bit per pixel for black/white images.
The Most Common Color Format - RGB
Windows Media Photo supports an extensive set of unsigned integer RGB pixel formats:
|
PixelFormat Name
GUID |
Ch |
BPC |
BPP |
Num |
Color |
A |
B |
|
WICPixelFormat24bppRGB
6fddc324-4e03-4bfe-b1853d77768dc90d |
3 |
8 |
24 |
UINT |
RGB |
|
ü |
|
WICPixelFormat24bppBGR
6fddc324-4e03-4bfe-b1853d77768dc90c |
3 |
8 |
24 |
UINT |
RGB |
|
ü |
|
WICPixelFormat32bppBGR
6fddc324-4e03-4bfe-b1853d77768dc90e |
3 |
8 |
24 |
UINT |
RGB |
|
|
|
WICPixelFormat48bppRGB
6fddc324-4e03-4bfe-b1853d77768dc915 |
3 |
16 |
48 |
UINT |
RGB |
|
ü |
|
WICPixelFormat32bppBGRA
6fddc324-4e03-4bfe-b1853d77768dc90f |
4 |
8 |
32 |
UINT |
RGB |
ü |
|
|
WICPixelFormat64bppRGBA
6fddc324-4e03-4bfe-b1853d77768dc916 |
4 |
16 |
64 |
UINT |
RGB |
ü |
|
|
WICPixelFormat32bppPBGRA
6fddc324-4e03-4bfe-b1853d77768dc910 |
4 |
8 |
32 |
UINT |
RGB |
ü |
|
|
WICPixelFormat64bppPRGBA
6fddc324-4e03-4bfe-b1853d77768dc917 |
4 |
16 |
64 |
UINT |
RGB |
ü |
|
|
WICPixelFormat16bppBGR555
6fddc324-4e03-4bfe-b1853d77768dc909 |
3 |
5 |
16 |
UINT |
RGB |
|
|
|
WICPixelFormat16bppBGR565
6fddc324-4e03-4bfe-b1853d77768dc90a |
3 |
5,6,5 |
16 |
UINT |
RGB |
|
|
|
WICPixelFormat32bppBGR101010
6fddc324-4e03-4bfe-b1853d77768dc913 |
3 |
10 |
32 |
UINT |
RGB |
|
|
The Basic formats include RGB in both 8bpc and 16bpc, plus 8bpc in BGR channel order.
RGB Channel Ordering
Let’s take a little detour to discuss channel ordering. The RGB color format is the only one where we have to deal with different channel ordering. Windows Media Photo’s support for different channel orders is largely for legacy reasons, providing support for the most commonly used ways of representing color. Ideally, channels would always be organized in the same order, simplifying the pixel format options. However, the existence of big-endian and little-endian processor architectures has led to different approaches for channel order of RGB data, requiring ongoing support for backward compatibility.
Historically, the industry has been inconsistent in the names for pixel formats compared to the specific ordering of channel values in an uncompressed image bit stream. We’ve made every effort to be consistent with Windows Media Photo. The pixel format name specifies the channel ordering as they appear in the sequential stream of uncompressed image data. Because of differences with big endian vs. little endian processor architectures, this becomes a little more confusing with channel values represented by 8bpc or less.
For a bitmap in 8bpc RGB pixel format (WICPixelFormat24bppRGB), the first byte in the uncompressed data stream is the red channel for the first pixel, followed by the green channel and then the blue channel. This is the typical way that 8bpc RGB data is stored in an uncompressed TIFF file. WICPixelFormat24bppBGR stores the channels in the reverse order, starting with the blue channel. This is the channel order used in 8bpc BMP files.
When a fourth channel is added to 8bpc pixel formats (either an alpha channel or an unused padding byte to align pixels on 32-bit word boundaries), the channel order of the bytes within a 32-bit word on a little-endian system are typically interpreted (and named) in the opposite order as they appear in the uncompressed data stream. However, with WIC pixel formats, the naming always references the channel order in the data stream, not how they might be reorganized within a larger pixel word on a little-endian system.
In addition to the Basic pixel formats, the set of unsigned integer RGB pixel formats include versions with normal and pre-multiplied alpha channels, an 8bpc version with an unused padding byte, and three different packed bit formats. We’ll save the discussion of alpha channels for another day.
WICPixelFormat32bppBGR is very similar to WICPixelFormat32bppBGRA; the only difference is that the latter uses the value in the fourth byte as an alpha channel while the former ignores it. These two pixel formats are very useful for storing an uncompressed pixel in a 32-bit word. The low order byte of the word is the blue channel, the next higher byte is green, then red, and the high order byte is either the alpha channel or unused, depending on the pixel format.
Packed Bit RGB Pixel Formats
Windows Media Photo supports three unsigned integer RGB packed-bit formats. These are formats where the bits per channel are not a multiple of 8-bit bytes. Because the channel values aren’t byte-aligned, the uncompressed data stream must be viewed as a sequence of pixel values rather than a sequence of channel values. The order of the channels within a pixel are defined within a word, and therefore, are dependent on whether the word is based on a big endian or little endian architecture.
Windows Media Photo always assumes a little endian (Intel/AMD) architecture, and the packed bit channel values are always organized accordingly. Therefore, a big-endian system must reorder the bytes within a word before interpreting the channel values.
WICPixelFormatBGR555 stores three 5-bit channel values in a single 16-bit word, with an unused bit. The least significant 5 bits are the blue value; the next 5 bits are the green value, followed by the red value. The most significant bit is unused. WICPixelFormatBGR565 increases the green channel to six bits, so all bits in a 16-bit word are used. These pixel formats are commonly used in hardware implementations, including displays in mobile devices. Windows Media Photo allows direct encoding in the device’s native pixel format.
WICPixelFormatBGR101010 stores three 10-bit channel values in a 32-bit word, with two unused bits. The least significant 10 bits are the blue value; the next 10 bits are the green value, followed by the red value. The most significant two bits are unused. This is a very useful format for increasing the precision of unsigned integer image data without a significant increase in uncompressed bitmap size. However, it can often be cumbersome to deal with 10-bit values, and the additional processing to extract the values outweighs advantages of saving storage space.
Support for Photo Printing
Windows Media Photo supports multiple pixel formats specifically designed for the needs of image printing. This includes numerous pixel formats in CMYK and n-Channel color formats.
Here are the CMYK pixel formats supported by Windows Media Photo:
|
PixelFormat Name
GUID |
Ch |
BPC |
BPP |
Num |
Color |
A |
B |
|
WICPixelFormat32bppCMYK
6fddc324-4e03-4bfe-b1853d77768dc91c |
4 |
8 |
32 |
UINT |
CMYK |
|
|
|
WICPixelFormat40bppCMYKAlpha
6fddc324-4e03-4bfe-b1853d77768dc92c |
5 |
8 |
40 |
UINT |
CMYK |
ü |
|
|