Re: NSImage and zooming PDFs vs. bitmaps
Re: NSImage and zooming PDFs vs. bitmaps
- Subject: Re: NSImage and zooming PDFs vs. bitmaps
- From: Hamish Sanderson <email@hidden>
- Date: Mon, 11 Aug 2008 09:15:22 +0100
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).
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