Re: iconForFile is slow
Re: iconForFile is slow
- Subject: Re: iconForFile is slow
- From: David Remahl <email@hidden>
- Date: Thu, 18 Apr 2002 13:03:02 +0200
>
icon = [[NSWorkspace sharedWorkspace] iconForFile:path];
>
>
iconForFile is very slow. Anyone written a faster replacement? One
>
problem is that I usually only need the 16x16 imagerep, but this call
>
returns a 16x16, 32x32 and 128x128.
>
>
Thanks,
>
>
-steve
Steve,
Troy Stephen's IconFamily class has a method:
- initWithIconOfFile:(NSString*)path
that gets an IconFamilyHandle for any file using Carbon calls. It also has
code for getting NSBitmapImageRep's from such a handle. The easiest thing is
to do:
IconFamily *iFam = [IconFamily iconFamilyWithIconOfFile:@"yourfile"];
NSImage *icon = [iFam imageWithAllReps];. That will do just what the
NSWorkspace method does and return all icon sizes.
I don't think there is any way to load just part of an icon from a resource
file, but there are ways that you can get any size once you got your
IconFamilyHandle.
Perhaps using IconRef's would be faster as well, I don't know.
/ David
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.