Click here to Skip to main content
13,198,467 members (65,610 online)
Click here to Skip to main content
Add your own
alternative version


12 bookmarked
Posted 30 Oct 2005

Color Value Formats

, 30 Oct 2005
Rate this:
Please Sign up or sign in to vote.
This application will show the currently selected color in three formats: RGB, hexadecimal, and interger.

Sample Image - Color_Value_Formats.jpg


This application will show the format of the currently selected color in three formats: RGB, hexadecimal, and integer. You can change the value in any format, and the other values will be adjusted accordingly.


This namespace provides all the colors used in the most common applications; if you want to make your own color, then this namespace provides the following function:

  • Color.FromArgb: Creates a Color structure from the four 8-bit ARGB component (alpha, red, green, and blue) values.

Hexadecimal Conversion

A integer value of the RBG color can be obtained from the Color.FromArgb(int argb) function. The following code will convert the decimal representation into the hexadecimal representation.

private string DeciamlToHexadeciaml(int number)
    string[] hexvalues={"0","1","2","3","4","5","6","7",
    string result=null, final=null;
    int rem=0,div=0;        


        if (number<16)

    for (int i=(result.Length-1); i>=0; i--)

    return final;

Current Color

The Current Color box will show the current color selected in different formats. The Current Color is displayed with the help of a PictureBox.


Decimal Conversion

When a change is made to the integer value of an RGB color, then this integer value is changed into the corresponding hexadecimal value.

private int GetNumberFromNotation(char c)
    if (c=='A')
        return 10;
    else if (c=='B')
        return 11;
    else if (c=='C')
        return 12;
    else if (c=='D')
        return 13;
    else if (c=='E')
        return 14;
    else if (c=='F')
        return 15;

    return Convert.ToInt32(c.ToString());

private int HexadecimaltoDecimal(string hexadecimal)
    int result=0;

    for (int i=0; i<hexadecimal.Length; i++)
    return Convert.ToInt32(result);


The idea for making this program came when I got frustrated while I was working on different graphical tools, the problem there is that some support the RDB color format, some support the hexadecimal format, and others....

So instead of having to calculate them myself again and again, I now have this nice program on my desktop :).


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Ali Raza Shaikh
Software Developer
Pakistan Pakistan
Ali Raza Shaikh did his BS (CS) from FAST-NUCES, Karachi Campus. He is also a Microsoft Certified Application Developer. He have a great passion for programming and all the programming related stuff. He can be reached at

You may also be interested in...

Comments and Discussions

QuestionWhy not??? Pin
lcdmendes26-Sep-07 8:57
memberlcdmendes26-Sep-07 8:57 
GeneralCool app Pin
reinux30-Oct-05 14:42
memberreinux30-Oct-05 14:42 
GeneralRe: Cool app Pin
Ali Raza Shaikh30-Oct-05 14:47
memberAli Raza Shaikh30-Oct-05 14:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171020.1 | Last Updated 30 Oct 2005
Article Copyright 2005 by Ali Raza Shaikh
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid