views:

446

answers:

1

I have an image in Fireworks. I am using the picker to choose the color and then look at the RGB values. I am putting these values into UIColor:colorWithRed:green:blue:alpha but it is not giving me the same output. I am using values between 1.0 and 0.0.

I am trying to get a dark blue color, the UIColor is giving me a very light blue.

Ideas?

+1  A: 

Sounds to me like your calculations for converting the value from fireworks to the value necessary in UIColor is off.

example:

Fireworks RGB values red:64 green:87 blue:188

divide those three number each by 255

gives you [UIColor colorWithRed:0.250980392156863 green:0.341176470588235 blue:0.462745098039216 alpha:1.0]

That basically worked, I tweaked it a few times till it looked how I wanted, the shading makes it a bit different than what I wanted. I tried doing [UIColor colorWithRed:0 green:20/255 blue:109/255 alpha:1] , but that gave me black. If I do the calculations on the fly like this, it always seems to give me black.
Chris
if you want to do the calculations on the fly then you need to make them with decimals so it calculates them as floats since the method requires CGFloat values to be passed in. in the example you use, 20/255 or 109/255 results in a 0 being passed in since you are doing division of integers not floats. so simply make if 20.0f/255.0f and 109.0f/255.0f and it will then give you the color instead of giving you black.