On Feb 15, 2012, at 7:32 AM, koko wrote:

> I want to capture a rect centered on the point where the user clicked so I 
> can get a best fit for the color.


Here's a thought:

        [NSEvent addGlobalMonitorForEventsMatchingMask:NSMouseMovedMask 
handler:^(NSEvent * event){
                if (event.type == NSMouseMoved) {
                        NSPoint point = [NSEvent mouseLocation];
                        CGRect mainDisplayBounds = 
CGDisplayBounds(CGMainDisplayID());
                        CGPoint cgDisplayPoint = CGPointMake(point.x, 
mainDisplayBounds.size.height - point.y);
                        CGRect rect = CGRectMake(cgDisplayPoint.x - 10, 
cgDisplayPoint.y - 10, 20, 20);
                        
                        CGImageRef imageRef = CGWindowListCreateImage(rect, 
kCGWindowListOptionOnScreenOnly, kCGNullWindowID, kCGWindowImageDefault);
                        magnifierView.image = [[[NSImage alloc] 
initWithCGImage:imageRef size:rect.size] autorelease];
                        CGImageRelease(imageRef);
                
                } else if (event.type == NSLeftMouseDown) {
                        if (this is supposed to be a color selection click) {
                                grab the pixel color from the image
                        }
                }
        }];



--
Seth Willits

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to