- Home /
convert float to color
can we able to convert float value of the Color pixel (U,V) to (R,G,B) format(255,120,128) format and display in label the color
do you mean going from #FFFFFF to 255,255,255 ? or do you mean from 1,1,1 to 255,255,255?
if that is the case, then google "color conversion to rgb" or something and you should be provided with some algorithms that should suit you.
can we able to display color content(R,G,B) in label or in a box my need is to display a R,G,B content separately in label or box
Answer by Jesse Anders · Mar 17, 2011 at 12:45 PM
Yes, you can display the values in a label.
You can convert a normalized float value to an integer in the range [0, 255] as follows (untested C#):
int result = (int)(value * 255f);
You can then construct a string representing the color as follows:
string text = string.Format("{0}, {1}, {2}", result_r, result_g, result_b);
That isn't the only way to do it, but it will work.