Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert RGB int values to string color

Tags:

c#

.net

wpf

Can anyone tell me how to convert three int vales r, g, b into a string color(hexa value) in C#

like image 647
saikamesh Avatar asked Mar 29 '11 18:03

saikamesh


People also ask

How do I convert RGB to string in Java?

How do I convert RGB to string in Java? format for all RGB colors: Color your_color = new Color(128,128,128); String hex = "#"+Integer. toHexString(your_color. getRGB()).

How do you convert RGB values to color names in Python?

There is a program called pynche which can change RGB to colour name in English for Python. You can try to use the method ColorDB. nearest() in ColorDB.py which can do what you want.

How do you convert RGB to integer?

So far I use the following to get the RGB values from it: // rgbs is an array of integers, every single integer represents the // RGB values combined in some way int r = (int) ((Math. pow(256,3) + rgbs[k]) / 65536); int g = (int) (((Math. pow(256,3) + rgbs[k]) / 256 ) % 256 ); int b = (int) ((Math.


1 Answers

int red = 255;
int green = 255;
int blue = 255;

string theHexColor = "#" + red.ToString("X2") + green.ToString("X2") + blue.ToString("X2");
like image 112
Tejs Avatar answered Sep 21 '22 23:09

Tejs