Get 'icl8' icon

Get 'icl8' icon

Post by anguye » Sun, 01 Feb 2004 07:43:04


I need to get the 'icl8' icon from a Mac OS X .icns file. The code I
use is as follows:

CFStringRef thePath = CFSTR("/Applications/Internet");
theAppURLRef = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
thePath, kCFURLPOSIXPathStyle, FALSE);

if (theAppURLRef != NULL)
theBundleRef = CFBundleCreate(kCFAllocatorDefault, theAppURLRef);
if (theBundleRef != NULL)
CFDictionaryRef theBundleInfoDict =
CFStringRef theIcnsFileName = (CFStringRef)
CFDictionaryGetValue(theBundleInfoDict, CFSTR("CFBundleIconFile"));
theMutIcnsFileName = CFStringCreateMutableCopy(kCFAllocatorDefault,
0, theIcnsFileName);
CFStringTrim(theMutIcnsFileName, CFSTR(".icns"));
CFURLRef theIcnsURLRef = CFBundleCopyResourceURL(theBundleRef,
theMutIcnsFileName, CFSTR("icns"), NULL);

if (theIcnsURLRef != NULL)
OSErr err;
FSRef theRef;
FSSpec theSpec;
FSRefParam theRefParam;
bool found = false;
IconFamilyHandle theIconFamilyHandle = NULL;

found = CFURLGetFSRef(theIcnsURLRef, &theRef);
if (found)
theRefParam.ref = &theRef;
theRefParam.whichInfo = kFSCatInfoNone;
theRefParam.catInfo = NULL;
theRefParam.spec = &theSpec;
theRefParam.parentRef = NULL;
theRefParam.outName = NULL;

err = PBGetCatalogInfoSync(&theRefParam);
if (err == noErr)
err = ReadIconFile(theRefParam.spec, &theIconFamilyHandle);
if (err == noErr)
IconSuiteRef icl8Ref = NULL;
Handle icl8 = NULL;

err = IconFamilyToIconSuite (theIconFamilyHandle,
kSelectorLarge8Bit , &icl8Ref);
err = GetIconFromSuite(&icl8, icl8Ref, 'icl8');





In this case (for Internet, GetIconFromSuite() returns
the desired 'icl8' data to the icl8 variable. It also works for However for, I get a NULL value for the icl8
variable (err is 0). Using IconComposer I open MacIE.icns and
app.icns. Both have the Large (32 x 32) icons. I assume they are the
8-bit large icons. I am not able to find any other tools to verify
that either the .icns file really does not have the 'icl8' data or
some thing is wrong with the code.

PowerBook G4 867Mhz
Mac OS 10.2.6
CW Pro 8.3, Carbon Target

Any help is appreciated,

Get 'icl8' icon

Post by Eric Alber » Sun, 01 Feb 2004 15:55:11

In article < XXXX@XXXXX.COM >,

Use icns Browser instead of Icon Computer. With icns Browser, you'll
see that Mail's app.icns file does not have an 8-bit 32x32 icon.

Hope this helps,

Eric Albert XXXX@XXXXX.COM ~ejalbert/


Get 'icl8' icon

Post by anguye » Mon, 02 Feb 2004 03:46:58

Thanks. That did it!