Re: Converting colorspace of a CGColor
Re: Converting colorspace of a CGColor
- Subject: Re: Converting colorspace of a CGColor
- From: Graham Cox <email@hidden>
- Date: Sun, 05 Apr 2015 14:31:54 +1000
> On 5 Apr 2015, at 12:19 pm, edward m taffel <email@hidden> wrote:
>
> perhaps I was unclear: if a «conversion» is desired, & by this I mean a conversion performed by a cmm
That isn't quite what I meant by conversion, though it may well end up doing what I want, at least on the Mac.
What I mean is that in order to do some calculations on a colour, I need them to be normalised to a 4-component RGBA format. So If I have a CGColorRef that is in the grayscale colorspace for example, I convert it to RGBA. (for gray that's trivial). For a color in the CMYK colorspace, that's not quite so trivial. But of course converting between colours that are calibrated to a particular CMM is going much further than that, and I'm not really needing that (it would probably be the right thing to do in a calibrated colour environment, but since that's not what exists on iOS, I'm compromising in that results on the Mac would not preserve a particular calibration).
Going back a step, I saw this in the documentation for CGGradientCreateWithColors():
>
> colors
> A non-empty array of CGColor objects that should be in the color space specified by space. If space is not NULL, each color will be converted (if necessary) to that color space and the gradient will drawn in that color space. Otherwise, each color will be converted to and drawn in the GenericRGB color space.
This led me to believe that there existed, within the Core Graphics API, a way to perform such a conversion. I also thought I'd recollected seeing one, though I can't recall what code I was working on at the time to find out what I did there. This is available in iOS, so it suggested there is a color conversion API somewhere there. It does also specifically exclude indexed or pattern colorspaces, but that's OK for my needs anyway.
It will probably suffice to comment my code such that it's clear that passing in any old CGColorRef is not good enough - it has to match the RGBA colorspace I use (and I can assert that). But ideally it would accept any color and convert it as needed exactly as CGGradient says it does.
--Graham
_______________________________________________
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