• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSImage Confusions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSImage Confusions


  • Subject: NSImage Confusions
  • From: Steve Gehrman <email@hidden>
  • Date: Thu, 18 Apr 2002 07:03:06 -0700

I'm trying to create an NSImage that contains only a files 16x16 icon.

Here's a distilled code snippet. Everything works great except for one file. I'll explain which file below.

- (NSImage*)getIcon:(NSString*)path;
{
NSImage* icon = [[NSWorkspace sharedWorkspace] iconForFile:path];
NSImage* sixteenImage = [[[NSImage alloc] initWithSize:NSMakeSize(16, 16)] autorelease];
NSArray* reps = [icon representations];
int i, cnt = [reps count];
NSImageRep *rep;

for (i=0;i<cnt;i++)
{
rep = [reps objectAtIndex:i];

if ([rep size].width == 16)
{
rep = [[rep copy] autorelease];
[sixteenImage addRepresentation:rep];
break;
}
}

return sixteenImage;
}

Everything works great, but there is one file that doesn't work. The file is an .html file. The icon for a .html file is part of IE and there seems to only be a 128x128 image defined in it's icns file. (At least I think this is the case). The NSImage returned from iconForFile for a .html file does have 3 bitmapimagereps (16, 32, 128).

When I use this code above, I get nothing when I try to draw this resulting image for a .html file. Strangely though, if I call this code again at a later time, it works! That is very strange. Any NSImage experts have a clue what is happening?

-steve
_______________________________________________
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.

  • Prev by Date: Problem with drag and drop
  • Next by Date: Porting a Win app to MAC 10
  • Previous by thread: Problem with drag and drop
  • Next by thread: Re: NSImage Confusions
  • Index(es):
    • Date
    • Thread