• 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: CGWindowListCreateImage fails on Snow Leopard with kCGNullWindowID
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CGWindowListCreateImage fails on Snow Leopard with kCGNullWindowID


  • Subject: Re: CGWindowListCreateImage fails on Snow Leopard with kCGNullWindowID
  • From: Jason Foreman <email@hidden>
  • Date: Thu, 10 Sep 2009 13:46:56 -0500

On Sep 10, 2009, at 12:34 PM, David Duncan wrote:

On Sep 10, 2009, at 7:32 AM, Jason Foreman wrote:

CGImageRef screenShot = CGWindowListCreateImage(CGRectInfinite, kCGWindowListOptionOnScreenOnly, kCGNullWindowID, kCGWindowImageDefault);



On Snow Leopard, the CGImageRef is NULL and the following message is printed to the console:

<Error>: CGImageCreate: invalid image bits/pixel or bytes/row.


Your bug will end up dup'd to <rdar://problem/7022171>. The basic problem is using CGRectInfinite from a 32-bit process when the Window Server is running as a 64-bit process – when the rect comes out at the other end it is no longer interpreted as "infinite" but rather as "very very large". Since you can't create an image that large, the creation code fails and you get back a NULL CGImageRef instead.

The current best work around is to determine a proper bounding box for the desktop and pass it for the given rect.

Thanks David, your suggestion works great. I appreciate the quick response.


For the benefit of the archives and anyone else having a similar issue, here is how I calculate the bounding box:

    NSRect desktopRect = NSZeroRect;
    for (NSScreen *screen in [NSScreen screens])
    {
        desktopRect = NSUnionRect(desktopRect, [screen frame]);
    }


This seems to give me exactly what I want when passed to CGWindowListCreateImage.



Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

References: 
 >CGWindowListCreateImage fails on Snow Leopard with kCGNullWindowID (From: Jason Foreman <email@hidden>)
 >Re: CGWindowListCreateImage fails on Snow Leopard with kCGNullWindowID (From: David Duncan <email@hidden>)

  • Prev by Date: setwantslayer:yes = rendering problem scaling subviews
  • Next by Date: [MEET] Reminder : LA CocoaHeads TONIGHT 9/10/09 at 7:30pm
  • Previous by thread: Re: CGWindowListCreateImage fails on Snow Leopard with kCGNullWindowID
  • Next by thread: UIImagePickerController problem
  • Index(es):
    • Date
    • Thread