Re: How to Convert "#FF00FF" String Specifying RGB Color to 32 bit int

2009-08-27 Thread Peter Zegelin
Sorry Graham - I should have mentioned that the color is rgba within the uint32. Thanks everyone - Robs solution worked great, though I'll have to strip off the # first and then shift to the left a further 8 bits. Never used NSScanner before but its a good solution. On 27/08/2009, at 9:50

Re: How to Convert "#FF00FF" String Specifying RGB Color to 32 bit int

2009-08-26 Thread Gideon King
Here's what we use to convert from an ARGB hex value to an NSColor - you could perhaps use a similar method and just shift the bytes and or them together as required for your unsigned int. + (NSColor *)colorWithHexARGB:(NSString*)hexString { unsigned int redByte, greenByte, blueByte,

Re: How to Convert "#FF00FF" String Specifying RGB Color to 32 bit int

2009-08-26 Thread Waqar Malik
Peter, I use NSScanner to parse the string to get individual values. NSRange range = NSMakeRange(1, 2); NSUInteger value = 0; [[NSScanner scannerWithString:[string substringWithRange:range]] scanHexInt:&value] // WARNING: code typed in email --Waqar On Aug 26, 2009, at 4:50 PM, Peter Zege

Re: How to Convert "#FF00FF" String Specifying RGB Color to 32 bit int

2009-08-26 Thread Rob Keniger
On 27/08/2009, at 9:50 AM, Peter Zegelin wrote: I have some xml where an rgb color value is specified via a "#XXYYZZ" type string. The xml is being read in via NSXMLParser. I can't seem to find an easy Cocoa way to convert this value to an unsigned int. I need an unsigned int rather than a

Re: How to Convert "#FF00FF" String Specifying RGB Color to 32 bit int

2009-08-26 Thread Graham Cox
On 27/08/2009, at 9:50 AM, Peter Zegelin wrote: Hi, I have some xml where an rgb color value is specified via a "#XXYYZZ" type string. The xml is being read in via NSXMLParser. I can't seem to find an easy Cocoa way to convert this value to an unsigned int. I need an unsigned int rather

How to Convert "#FF00FF" String Specifying RGB Color to 32 bit int

2009-08-26 Thread Peter Zegelin
Hi, I have some xml where an rgb color value is specified via a "#XXYYZZ" type string. The xml is being read in via NSXMLParser. I can't seem to find an easy Cocoa way to convert this value to an unsigned int. I need an unsigned int rather than an NSColor as the value is used in C+ + code.