On 29/05/2011, at 3:50 PM, Roland King wrote:

> You can use CGColorGetComponents on a CGColorRef to get the values of 
> whatever colorspace the CGColorRef is in and you can create new CGColorRefs 
> with those values. 
> 
> I don't see a way to convert from one colorspace to another however a quick 
> test on one UIColor constructed with HSV values shows its contained 
> CGColorRef to have an RGB colorspace which you could get the RGB values from. 
> Whether you can rely on that I don't know and haven't found any documentation 
> to back it up. 


Thanks Roland, and Kyle too.

I found the same thing, so going from HSV -> RGB isn't a big problem. I'm 
pretty sure HSV isn't a different colourspace, it's just a convenient way to 
interpret RGB values. Using some simple code I looked up on the web, I wrote a 
method to return the RGB colour as HSV. Seems to give me the results I was 
looking for (since it's just for making some nice-looking gradients, it's not 
critical that it has super-accuracy, though I believe the code to be accurate 
anyway).

--Graham

_______________________________________________

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

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

Reply via email to