Re: iconForFile
Re: iconForFile
- Subject: Re: iconForFile
- From: Lorenzo <email@hidden>
- Date: Fri, 16 Nov 2007 14:32:02 +0100
Did you try to display the icons of the folders in the Home folder?
I mean, Music, Pictures, Documents, Public, Sites...
Anyway iconForFile works slowly even with normal folders.
I could display a pre-loaded folder icon, but in this case I cannot longer
show the icons of the above special folders.
Best Regards
--
Lorenzo
email: email@hidden
> From: Ron Fleckner <email@hidden>
> Date: Fri, 16 Nov 2007 12:23:44 +1100
> To: Lorenzo <email@hidden>
> Cc: email@hidden
> Subject: Re: iconForFile
>
>
> On 16/11/2007, at 11:29 AM, Lorenzo wrote:
>
>> Hi,
>> I use [NSWorkspace sharedWorkspace] iconForFile:filePath] to get
>> the 128x128
>> icon of a file or a folder. It works well, but it is amazingly
>> slow. It get
>> the icon in about 1 second, much more that getting a thumbnail of a
>> large
>> jpg file by CGImageSourceCreateThumbnailAtIndex.
>> Is a faster way, even an old carbon way, working on Tiger and Leopard?
>>
>>
>> Best Regards
>> --
>> Lorenzo
>> email: email@hidden
>
> Well, on my machine (G4 DP 1.25Ghz 1 Gig RAM)), it takes 0.002
> seconds to do it. There is something else happening in your case I
> reckon.
>
> Here's my complete IBAction:
>
> - (IBAction)chooseFile:(id)sender
> {
> NSOpenPanel *panel;
> NSString *chosenFile;
> int result;
> NSString *title = @"Choose the file";
> NSString *okButtonTitle = @"Choose";
> panel = [NSOpenPanel openPanel];
> [panel setCanChooseDirectories:YES];
> [panel setCanChooseFiles:YES];
> [panel setAllowsMultipleSelection:NO];
> [panel setTitle:title];
> [panel setPrompt:okButtonTitle];
> result = [panel runModalForDirectory:nil file:nil types:nil];
>
> NSLog(@"time 1");
>
> if (result == NSOKButton) {
> chosenFile = [panel filename];
> NSImage *aImage = [[NSWorkspace sharedWorkspace]
> iconForFile:chosenFile];
> [myView setFileIcon:aImage];
> [myView setSize:NSMakeSize(128.0,128.0)];
> [myView setNeedsDisplay:YES];
> [slider setFloatValue:128.0];
> [currentSize setStringValue:@"128"];
> }
>
> NSLog(@"time 2");
> }
>
> 2007-11-16 12:19:00.538 GetFileIcons[4121] time 1
> 2007-11-16 12:19:00.540 GetFileIcons[4121] time 2
>
> Ron
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden