How can I find out what non-RGB pixel formats a codec supports?

Q: Is there a way for an application to query a codec and find out what non-RGB pixel formats it supports?

A: Codecs supporting non-RGB pixel formats should have a 'cpix' resource included in their public resource list containing the four character codes of their supported non-RGB pixel formats. This information can be retrieved by applications using GetComponentPublicResource.

Listing 1 demonstrates how an application can check to see if a specific non-RGB pixel format is supported by a codec.

Listing 1:

Boolean DoesCodecSupportPixelFormat(Component inComponent,
                                    OSType    inFormat)
{
  Boolean   isSupported = false;
  OSTypePtr *hResource = NULL;
  long      thePixelFormatCount;
  int       i;
  OSErr     err;

  // NOTE: GetComponentPublicResource returns a Handle,
  // not a resource - the caller should dispose this using
  // DisposeHandle

  err = GetComponentPublicResource(inComponent,
                                   'cpix', 1,
                                   (Handle*)&hResource);
  if (err || (NULL == hResource)) goto bail;

  thePixelFormatCount = GetHandleSize((Handle)hResource) / 4;

  for (i = 0; i < thePixelFormatCount && !isSupported; i++)
    isSupported = ((*hResource)[i] == inFormat);

  DisposeHandle((Handle)hResource);

bail:
  return isSupported;
}

Codec Developers

A codec advertising support for '2vuy', 'r408' and 'v408' would for example, include a 'cpix' resource as part of their public resource list which looks like Listing 2.

Listing 2:

resource 'cpix' (kMyCPIXResID) {
 {
     '2vuy','r408','v408'
 }
};

Back to Top 

Document Revision History

DateNotes
2008-04-24Editorial
2004-01-05Applications can find out if a codec supports non-RGB pixel formats.

Posted: 2008-04-24


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.