Re: NSImage and zooming PDFs vs. bitmaps
Re: NSImage and zooming PDFs vs. bitmaps
- Subject: Re: NSImage and zooming PDFs vs. bitmaps
- From: Ken Ferry <email@hidden>
- Date: Mon, 11 Aug 2008 09:52:32 -0700
On Aug 11, 2008, at 1:15 AM, Hamish Sanderson <email@hidden
> wrote:
On 8 Aug 2008, at 17:53, Ken Ferry wrote:
The correct answer is to call setDataRetained:YES on your image.
However, there may be a bug in Leopard and previous with NSImage
cache
expiration that prevents that from being enough. If you seem to be
hitting it, you can probably work around it by additionally turning
off caching entirely (setCacheMode:NSImageCacheNever) or maybe by
manually invalidating the image cache (-[NSImage recache]) when you
are changing the scale.
Yay! A combination of -setDataRetained: on image loading and -
recache on zooming did the trick, although I did need to kludge in a
size check before calling -recache as rasterising an entire PDF
above ~10,000x10,000 quickly gets painful performance- and memory-
wise. Obviously there are ways to rasterise just the visible portion
on an as-needed basis (c.f. PDFKit's PDFView), but I suspect this is
non-trivial to implement so I'll see if users can live with the
current resolution limit (which is still a big improvement from
before).
For drawing that would lead to a very large raster cache, NSImage
prefers to draw directly from the source rather than make a cache.
However, it sounds like this isn't doing it for you. Could you file a
bug with a demonstration app?
Perhaps you could try just turning caching off, or turning it off when
the scale factor is high? As you said, at some point the cost of
making and holding the cache outweighs the cost of just drawing from
the PDF.
Also, sorry, there's nothing built-in that caches partial images or
holds caches for multiple destination sizes.
-Ken
Cocoa Frameworks
Out of interest, is there an easy way to make NSImage retain and
reuse these different sized cached representations rather than
throwing them away each? At the moment, things get a bit sluggish
every time you zoom into details; it'd be nice if it only had to be
sluggish the first time. The NSImage API looks like it should be
able to do this, but I'm having trouble getting my head around it.
Any pointers?
Many thanks,
Hamish
--
Hamish Sanderson
Production Workflow Developer
Sun Branding Solutions Ltd
Tel: +44(0)1274 200 700
www.s-brandingsolutions.com
_______________________________________________
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