How to convert Hex to RGB?

后端 未结 8 1564
暖寄归人
暖寄归人 2021-02-12 11:13

I am trying to use this to figure out if a color is light or dark

Evaluate whether a HEX value is dark or light

Now. It takes in a int



        
8条回答
  •  死守一世寂寞
    2021-02-12 11:55

    The ranges of the R, G and B from the Color struct are 0-255.

    To get the rgb value you expect in your function, you will need to left shift accordingly:

    int rgb = (int)color.R << 16 + (int)color.G << 8 + color.B;
    

提交回复
热议问题