• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSView to NSImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >NSView to NSImage (From: Tristan Jehan <email@hidden>)
 >Re: NSView to NSImage (From: Michael Watson <email@hidden>)
 >Re: NSView to NSImage (From: Tristan Jehan <email@hidden>)

  • Prev by Date: Re: List of installed apps
  • Next by Date: Re: KVO and the observeValueForKeyPath bottleneck
  • Previous by thread: Re: NSView to NSImage
  • Next by thread: Re: How to "clean" an Xcode Project File of old references...
  • Index(es):
    • Date
    • Thread