On 30/06/2010, at 6:36 PM, Ken Ferry wrote:

> On Mon, Jun 28, 2010 at 8:24 PM, Graham Cox <graham....@bigpond.com> wrote:
> I have an NSImage which I generate by specifically creating a NSPDFImageRep 
> and adding that to an empty image. Later this same image rep is used to write 
> the image as a PDF file to disk.
> 
> An interface displays these images, either loaded from disk or made on the 
> fly as above. The image's native size is quite small and they are often 
> scaled up when drawn, but since they're PDFs that should work OK.
> 
> On 10.6, these render really nicely and I always get crisp drawing. On 10.5 
> however, they render quite fuzzily, which I'd prefer they didn't.
> 
> Obviously the problem is the bitmap caching that NSImage does, and which must 
> have changed for PDF images in 10.6. I set the caching of the image to 
> NSImageCacheBySize, which gives me a useful drawing speed-up compared with 
> NSImageCacheNever, but the cached bitmaps are fuzzy on 10.5, presumably 
> because they're being scaled up and the bitmaps cached the original size, not 
> the drawn size. Is there anything I can do about this?
> 
> I set the context's image interpolation quality to high when these are drawn.
> 
> Hi Graham,
> 
> I'm a lot more familiar with the post-10.6 code than the 10.5 and before 
> code, but I think you probably need to either turn off the cache or 
> essentially manage your own cache by replacing the image when the scaling 
> changes.  
> 
> Given that this problem is fixed in newer OSes, I would be tempted to just 
> turn off the cache in 10.5.


Hi Ken, thanks for the suggestion.

I've tried that, but the results are strange - I'm not sure I really understand 
what's going on.

When I render these icons, I do so in a custom cell which can either operate 
using NSImageScaleProportionallyDown, or NSImageScaleProportionallyUpOrDown. 
The user is able to switch between these to show icons either at actual size 
(or smaller), or scaled up to fill the cell.

Whichever one is displayed first, it seems to "fix" the resolution of the icon 
at that size forever after, even though caching is supposedly off and the cache 
has been cleared (-recache). So it's still caching the PDF to a bitmap it 
seems, at least on 10.5 (As I said on 10.6 I have none of these issues).

Do I need to manipulate the cache setting for the PDF image rep itself? I 
thought that whatever you set NSImage to do applied to all its reps, no? The 
docs say that NSPDFImageRep sets NSImageCacheAlways by default, so does passing 
'never' to its containing image actually change this?

The cell drawing code is clean, as far as I can see (does nothing but draw the 
image, it doesn't change the image's state in any way), and loading the icon is 
little more than doing [NSImage imageWithContentsOfFile:] followed by setting 
the cache to NSImageCacheNever and calling -recache.

Mystified......

--Graham


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to