Re: Getting CGColor components
Re: Getting CGColor components
- Subject: Re: Getting CGColor components
- From: Development <email@hidden>
- Date: Sat, 11 Jun 2011 17:23:20 -0700
:\
I think I have it figured out
All colors work except white and black.
I had to detect those and build the rgb manually
On Jun 11, 2011, at 4:12 PM, Development wrote:
> According to all the examples I have found the following code should give me the RGB components of any UIColor.CGColor I pass to it....
>
> However I get back a scrambled and often inaccurate array of color values which turns out to be useless.
>
> CGFloat colors[[widgetArray count]*4];
>
>
>
> id * item;
> int idx=0;
> for (item in widgetArray) {
>
>
>
> const CGFloat *comp = CGColorGetComponents(item.backgroundColor.CGColor);
> const CGFloat *c = CGColorGetComponents(item.backgroundColor.CGColor);
>
> colors[idx] = comp[0];
>
> colors[++idx] = comp[1];
>
> colors[++idx] = comp[2];
>
> colors[++idx] = c[CGColorGetNumberOfComponents(item.backgroundColor.CGColor)-1];
>
> idx++;
>
> }_______________________________________________
>
> 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
_______________________________________________
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