• 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:Getting the color under the cursor
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Prev by Date: Intercepting Click in Background of Table View
  • Next by Date: Re: Wrapped list of cells?
  • Previous by thread: Getting the color under the cursor
  • Next by thread: How to bind only on edit?
  • Index(es):
    • Date
    • Thread