Re: Find color's change in a NSString (attributed)
Re: Find color's change in a NSString (attributed)
- Subject: Re: Find color's change in a NSString (attributed)
- From: Izidor Jerebic <email@hidden>
- Date: Tue, 21 Feb 2006 11:28:17 +0100
On 21.2.2006, at 10:59, Andrea Salomoni wrote:
Hi to all,
I already find the way to parse correctly the attributed string,
and I can read the dictionary with NSColor key....
But the problem is the following:
My function returns me this line string: NSCalibratedRGBColorSpace
0.531465 1 0.821694 1
This is the output when logged to console, but the value in
dictionary is in fact NSColor object. What you see above is the
description of this object.
I need only the rgb value to convert it a a websafe color (or an
html version of this color)....
I cannot use the method [myAttributesDictionary
valueForKey:@"NSColor"]; because the string is filled with not only
the rgb values....
This code snippet should get you RedGreenBlue components in float
variables or error message if this is some incompatible color:
NSColor *color ;
NSColor *rgbColor ;
float r, g, b, a ;
color = [myAttributesDictionary valueForKey:@"NSColor"] ;
rgbColor = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace] ;
if( rgbColor != nil ) {
[rgbColor getRed:&r green:&g blue:&b alpha:&a] ;
}
else {
NSLog( @"Can't get RGB components out of %@", color ) ;
}
izidor
_______________________________________________
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