• 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
Screen snapshot example code posted
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Screen snapshot example code posted


  • Subject: Screen snapshot example code posted
  • From: Ben Haller <email@hidden>
  • Date: Fri, 12 Aug 2005 21:48:12 -0700

Those who have used NSBitmapImageRep's method - initWithFocusedViewRect: in a transparent window to get a screenshot probably know that that broke on 10.4 due to changes in the underlying video architecture. Apple has (through informal channels) told me that that is unlikely to be fixed, as it was never particularly documented or intentional behavior to begin with. So a need for a different method has come about. Thus the example code I've just posted on my website:

http://www.sticksoftware.com/developer/samplecode.html

This code uses CopyBits to make a QuickDraw Picture, and then gets it into Cocoa via NSPICTImageRep. It feels a little like pounding a square peg into a round hole, but it works and it's pretty fast.
Ryan Bates wrote much of this code; I just made it work on multiple monitors, which turned out to be trivial. As a comment in the code indicates, it will probably stop working at some point in the future since CopyBits has been deprecated in 10.4 (talk about the end of an era), but it works for now. :-> If anybody has better code they would like to share, that would be most welcome. I searched the cocoa-dev archives and didn't find anything helpful. Presumably there's a way to do this through CoreGraphics or CoreImage, but I don't know those APIs...
I've logged a bug on Apple that they ought to provide an example of how to do this correctly, using public, non-deprecated APIs. Or better yet, add a new factory method to NSImage that makes an image from the screen pixels. I have no idea if they intend to pay any attention to me. :->


Ben Haller
Stick Software

_______________________________________________
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


  • Follow-Ups:
    • Re: Screen snapshot example code posted
      • From: Andreas Mayer <email@hidden>
  • Prev by Date: NSStepper, NSDatePicker
  • Next by Date: Re: APIs to work with zip archives
  • Previous by thread: Re: NSStepper, NSDatePicker
  • Next by thread: Re: Screen snapshot example code posted
  • Index(es):
    • Date
    • Thread