Re: Grabbing what's behind a window
Re: Grabbing what's behind a window
- Subject: Re: Grabbing what's behind a window
- From: Mike Paquette <email@hidden>
- Date: Mon, 29 Oct 2007 17:22:33 -0700
On Oct 29, 2007, at 3:49 PM, Kenny Leung wrote:
Dear Graphics Gurus:
I'm trying to make a transparent "lens" effect on the screen using a
core-image filter. When it's time to update, I orderOut the window
I'm drawing in, grab the background, and then orderFront the window
with the transformed contents. Unfortunately, this does not work - I
keep grabbing the contents of my own window. I have tried the
orderOut, then doing the grab in a performSelector:afterDelay, but
this generates an annoying flicker.
I'm wondering if what I'm trying to do is an impossibility - or is
there some trick by which it can be done?
Thanks!
-Kenny
Starting in Mac OS X 10.5 On Mac OS X 10.5 you can read back
information on other windows within the same GUI session as the
calling process using the CGWindow API (defined in /System/Library/
Frameworks/ApplicationServices.framework/Frameworks/
CoreGraphics.framework/Headers/CGWindow.h).
Images can be generated from a list of windows passed to
CGWindowListCreateImageFromArray(), or from a set of selection
conditions ("All windows below this window") passed to
CGWindowListCreateImage(). Various options control the bounds and
content of the resulting image.
In your case, you would want to grab an image for a specific rect for
all windows below your window. (The grab will stop as soon as it
reaches an opaque window.)
NSRect frame = [myWindow frame];
CGWindowID wid = (CGWindowID)[myWindow windowNumber];
CGImageRef image = CGWindowListCreateImage( *(CGRect *)&frame,
kCGWindowListOptionOnScreenBelowWindow, wid,
kCGWindowImageDefault );
Refer to the comments in the header file for information on using
these new APIs.
Mike Paquette
CoreGraphics Team
_______________________________________________
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