| Q: Are there any guidelines for the value of the depth field when creating Image Descriptions?A: The Image Compression Manager uses Image Descriptions to describe compressed and uncompressed image data. Sometimes these are created for you by an API like MakeImageDescriptionForPixMaporGraphicsImportGetImageDescription. However, sometimes you need to create an image description yourself. The depthfield of an image description does not always contain a literal number of bits per pixel. Instead, it should be the QuickDraw pixel size that most closely describes the image data. This enables applications to broadly understand properties of a compressed image without needing to know specific details. Information about where the true depth gets stored is covered in 'Section 2' of this document. Section 1 - The Depth FieldWhen filling in the depthfield directly, use the following guide: If the image has an alpha channel, always use 32.If the image is grayscale, use a grayscale depth:If the image is indexed color (ie, each sample is interpreted through a color look-up table), use the appropriate color depth;   In these cases, the color table must be attached to the image description. You can do this by calling SetImageDescriptionCTable. 8 for 256 color4 for 16 color2 for 4 color1 for Monochrome
If the image is a 16-bit RGB pixel format, use 16.
 Otherwise use 24 if the image doesn't match any of the above criteria. This is the generic "color with no alpha channel" depth. For YUV pixel formats without alpha, use 24. Although YUV9 is 9 bits per pixel, YUV 4:2:0 is 12 bits per pixel, and YUV 4:2:2 is 16 bits per pixel, you should still use 24. Follow the above guidelines even for pixel formats with samples deeper than 8-bit. For example, 48-bit RGB should use depth 24 and 64-bit ARGB should use depth 32. Table 1: Quick Summary Guide | Image type | Depth value to use | 
|---|
 | Has an alpha channel | 32 |  | 256 indexed color - requires CTable | 8 |  | 16 indexed color - requires CTable | 4 |  | 4 indexed color - requires CTable | 2 |  | 2 indexed color - requires CTable | 1 |  | 8-bit or deeper grayscale | 40 |  | 4-bit or grayscale | 36 |  | 2-bit or grayscale | 34 |  | 1-bit or grayscale | 33 |  | 16-bit RGB pixel format - any flavour | 16 |  | YUV pixel formats without alpha | 24 |  | Color with no alpha channel - generic depth | 24 |  | 48-bit RGB | 24 |  | 64-bit ARGB | 32 |  | 32-bit grayscale with alpha | 32 |  | 16-bit grayscale | 40 | 
 QTGetPixelFormatDepthForImageDescription(available in QuickTime 6.0 and greater) returns the appropriate depth code for any registered pixel format.
 Back to Top  Section 2 - Where should information about the true depth get stored?When the image data in question is an uncompressed pixel array of a big-endian pixel format that QuickDraw supports (specifically, 1, 2, 4, 8, 16, 24, 32, 33, 34, 36, or 40), the cTypefield of the image description should bekRawCodecTypeand thedepthfield (as discussed above) should be the pixel format. For example, for 8-bit grayscale, thecTypefield should containkRawCodecTypeand thedepthfield should contain 40. When the image data in question is an uncompressed pixel array of a non-QuickDraw pixel format, the cTypefield of the image description should be the pixel format code. For example,k2vuyPixelFormat('2vuy'). In this case thedepthfield (as discussed above) should contain 24. For 16-bit grayscale, thecTypefield should containk16GrayCodecTypeand thedepthfield should contain 40. When the image data in question is compressed, but has a special native pixel format that it can be decompressed directly into, the pixel format should be stored as a big-endian OSType in an image description extension of type kImageDescriptionColorSpace('cspc'). The value of thecTypefield should reflect the way the image data was compressed. For example, a PNG file containing a 48-bit-per-pixel RGB image would be described by an image description with a cTypeofkPNGCodecType('png '), a big-endiankImageDescriptionColorSpace('cspc') image description extension containing the OSTypek48RGBCodecType('b48r') and adepthfield (as discussed above) containing the value 24. If your application needs more detailed information about registered pixel formats, use ICMGetPixelFormatInfo. Back to Top  ReferencesBack to Top  Document Revision History| Date | Notes | 
|---|
 | 2006-11-27 | editorial |  | 2002-08-15 | Describes how to select the correct value for the depth field of an image description. | 
 Posted: 2006-11-27 |