Re:Getting the color under the cursor
Re:Getting the color under the cursor
- Subject: Re:Getting the color under the cursor
- From: Anish Kumar <email@hidden>
- Date: Fri, 08 Jul 2005 11:47:05 +0530
- Organization: Qubyx Software Technologies.
Hi Brain,
Here is a sample code that get the color values in RGB and HSB. You
can use this under the mouseOver: or mouseDown: methods.
float
red,green,blue,cyan,yellow,magenta,black,hue,saturation,bright,alpha;
NSColor *pixelColor;
[self lockFocus]; // NSReadPixel pulls data out of the current
focused graphics context, so -lockFocus is necessary here.
pixelColor = NSReadPixel(pixelPosition); //pixelPosition is of
type NSPoint and has the value of the position where you want to read
the color
[self unlockFocus]; //
// For RGBColorSpace
[[ pixelColor
colorUsingColorSpaceName:NSCalibratedRGBColorSpace]getRed:&red
green:&green
blue:&blue
alpha:&alpha];
//For HueColorSpace
[[ pixelColor
colorUsingColorSpaceName:NSCalibratedRGBColorSpace]getHue:&hue
saturation:&saturation
brightness:&bright
alpha:&alpha ];
To get CMYK values that can match with the kind of values you get in
Photoshop, you have to use profiles for converting the RGB values to CMYK.
Hope this is what you were looking for......
/ regards,
-Anish Kumar VK
Software Engineer, MAC OS X,
http://www.qubyx.com/ /
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden