• 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: [ Was NSReadPIxel ]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >[ Was NSReadPIxel ] (From: koko <email@hidden>)

  • Prev by Date: Re: CGContextSaveGState
  • Next by Date: Re: CGContextSaveGState
  • Previous by thread: [ Was NSReadPIxel ]
  • Next by thread: Re: [ Was NSReadPIxel ]
  • Index(es):
    • Date
    • Thread