Re: NSView to NSImage
Re: NSView to NSImage
- Subject: Re: NSView to NSImage
- From: Michael Watson <email@hidden>
- Date: Mon, 17 Jul 2006 18:40:49 -0400
It really depends on what kind of data is being displayed in the
views you're attempting to capture. NSBitmapRep doesn't seem to be
able to see through all views and see all content types like -
dataWithPDFInsideRect: can.
[view lockFocus];
NSImage *image = [[NSImage alloc] initWithData:[view
dataWithPDFInsideRect:[view bounds]]];
[view unlockFocus];
The view itself is returning a rendered PDF representation of the
data within it and its subviews. NSBitmapImageRep seems to work
differently, but I'm not quite sure how.
For most purposes, NSBitmapImageRep is sufficient (it's also faster,
I believe), but occasionally you'll come across something that it
can't capture. (QTMovieView, for example, will render blank white
with NSBitmapImageRep, whereas NSView's -dataWithPDFInsideRect: will
get the job done correctly.
--
Michael Watson
On 17 Jul, 2006, at 17:53, Tristan Jehan wrote:
Michael,
The "second" solution worked perfectly!
The first didn't do the right thing, perhaps because my view wasn't
visible on screen...
Thanks!
Tristan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden