On 12/15/09 14:32, "Christiaan Hofman" <cmhof...@gmail.com> wrote:

> 
> On Dec 15, 2009, at 23:07, Maxwell, Adam R wrote:
> 
>> On 12/15/09 13:51, "Christiaan Hofman" <cmhof...@gmail.com> wrote:
>> 
>>> 
>>> On Dec 15, 2009, at 22:31, Maxwell, Adam R wrote:
>>> 
>>>> On 12/15/09 13:04, "Christiaan Hofman" <cmhof...@gmail.com> wrote:
>>>> 
>>>>> 
>>>>> On Dec 15, 2009, at 20:09, Maxwell, Adam R wrote:
>>>>> 
>>>>>> I notice this is removed, but recall that the centering/scaling is only
>>>>>> part
>>>>>> of that cell; using -[NSImage bestImageRepForSize:device:] is possibly
>>>>>> the
>>>>>> more important part, since NSImage often picks a poor representation at
>>>>>> many
>>>>>> sizes.  This is really noticeable with system images that have multiple
>>>>>> reps.  It may be fixed on 10.6 if NSImage/NSImageCell uses
>>>>>> -bestRepresentationForRect:context:hints:, but NSImage caching might
>>>>>> still
>>>>>> get in the way, unless they've fixed it.
>>>>>> 
>>>>>> -- 
>>>>>> Adam
>>>>> 
>>>>> The release notes indicate a lot of changes to image caching.
>>>> 
>>>> Yeah, things improved a lot in 10.6.  NSImage is probably fixed as much as
>>>> it can be, short of dumping it entirely.
>>>> 
>>>>> And AFAICS 
>>>>> NSImageCell draws the correct rep, with the minimum size just larger or
>>>>> equal
>>>>> to the target rect. Would you have a test case where things were drawn
>>>>> poorly?
>>>> 
>>>> Draw a URL icon in a tableview.  IIRC if the image has a rep of size 16 and
>>>> the cell wants an image of that size, it will use it; otherwise, it uses
>>>> the
>>>> largest rep and scales it down.  You used to see this in the main table by
>>>> playing with the icon column widths.  At one size it would draw just an "@"
>>>> in sharp detail, but at a slightly different size it would draw the "@"
>>>> with
>>>> a fuzzy "HTTP" below it.
>>> 
>>> I don't see that, at least on 10.6.2. I'm pretty sure it's using the next
>>> largest rep.
>> 
>> That's good, then; I'm not exactly sure what the behavior was, but I saw the
>> symptoms often enough.  I tried to find a mailing list post that talked
>> about the same thing, but I'm losing my touch with google.
>> 
>>>> It's also very worthwhile to badge individual reps of system icons, say if
>>>> you want to apply a CIFilter and change the color (and maybe you do
>>>> this...I
>>>> haven't looked recently).  I found that you can end up with some nasty edge
>>>> artifacts otherwise.
>>> 
>>> I'm not completely sure what you mean, but at least for group icons based on
>>> system icons I create both a 16 and 32 rep (I don't think it's worthwhile to
>>> have a 128 rep).
>> 
>> Basically that; I think I stole your idea of tinting the system images :).
>> I just do it for(rep in [image representations]).
> 
> That does not always work, because some system images (e.g. smart folder is
> one) have only one (NSCoreUIImageRep) rep that draws differently at different
> sizes, rather than different reps for the different sizes.

Yeah, if you use the +[NSImage imageNamed:], you get the CoreUI thing.
However, you get an array of NSIconRefBitmapImageReps from [[NSWorkspace
sharedWorkspace] 
iconForFileType:NSFileTypeForHFSTypeCode(kGenericFolderIcon)] or
[[NSWorkspace sharedWorkspace] iconForFileType:@"savedSearch"]).  Those are
NSBitmapImageRep subclasses, so you can create a CIImage from each rep and
filter it, then create a new NSBitmapImageRep from the output CIImage.  Each
bitmap then gets added to an NSImage.  I have a trivial fallback in case
those stop being bitmap reps, but 10.5 and 10.6 are okay.
  
>>> BTW, I got a problem with bestImageRepForSize:device:. The returned rep can
>>> be
>>> nil, for instance when the target size is larger than the largest rep (or
>>> when
>>> the colorspace name is different). You've got an idea?
>> 
>> Sorry, I could swear I checked in a fix for that!  The last line should be
>> 
>>    // if no rep of appropriate size, use NSImage's idea of the best one for
>> the device
>>    return toReturn ? toReturn : [self
>> bestRepresentationForDevice:deviceDescription];
> 
> I just fixed the main problem by returning the largest rep when that's smaller
> than the required size.

Good point, that's another potential problem.  I'd only run into the
colorspace problem.

> Actually, bestRepresentationForDevice: is now
> deprecated.

But it still works, at least as well as it ever did.  Unless you get
warnings with a deployment version, it's usually more trouble than it's
worth to special case deprecated methods.


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Bibdesk-develop mailing list
Bibdesk-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-develop

Reply via email to