Re: [ Was NSReadPIxel ]
Re: [ Was NSReadPIxel ]
- Subject: Re: [ Was NSReadPIxel ]
- From: Seth Willits <email@hidden>
- Date: Wed, 15 Feb 2012 13:06:33 -0800
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 (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