Re: Getting a file's icon > 32x32 (Solved)
Re: Getting a file's icon > 32x32 (Solved)
- Subject: Re: Getting a file's icon > 32x32 (Solved)
- From: Brant Vasilieff <email@hidden>
- Date: Tue, 29 Jan 2002 11:15:11 -0800
On Monday, January 28, 2002, at 04:48 PM, email@hidden wrote:
look at the imageReps inside the NSImage... there are typically
several. you have to look for the 128x128 one.
Thanks. The reps appear to be sorted in descending order. Don't know
if it's guaranteed, but it looks reliable enough with one file, to let
me experiment.
I can get the correct imageRep and draw it, but that opens up a whole
new can of worms. I'm drawing within a NSBrowserCell subclass which
resides in a NSMatrix. In order to get the matrix to place cell top to
bottom instead of bottom to top, it is necessary to flip the coordinates
in NSMatrix. That causes the image to draw upside down. Ok, I can call
setFlipped: on the image to correct it. Unfortunately that doesn't work
for image reps.
Another problem with image reps, is that there is no direct method to
compose them and pick the operation mode. So when drawing the imageRep
directly, I get black borders where the image is transparent.
The first idea was to either remove the unwanted image reps, or create a
new image from just the larger image rep, and then I could call all of
the NSImage's drawing and composting methods.
But then after some more thinking, I started wondering why the default
was preset to 32x32, and would changing the size, cause it to pick a
different preferred representation.
So I set the images size to 128x128, and it appears to work fine. I get
the fine detail of a true 128x128 image drawn upright, and without any
black borders.
So thanks to all who helped. Especially Rainer Brockerhoff who's answer
bellow watches verbatim, what I came up with last night while watching
Rose Red.
_image = [[[NSWorkspace sharedWorkspace] iconForFile:inPath] retain];
[_image setSize:NSMakeSize(128,128)];
Thanks again,
Brant