Retired Document
Important: This document may not represent best practices for current development. Links to downloads and other resources may no longer be valid.
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' |
} |
}; |
Document Revision History
Date | Notes |
---|---|
2008-04-24 | Editorial |
2004-01-05 | New document that applications can find out if a codec supports non-RGB pixel formats. |
Copyright © 2008 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2008-04-24