Solved

Convert ColorDialog control colors to ARGB and color type questions

Posted on 2007-04-04
1
500 Views
Last Modified: 2008-02-07
I am allowing the user to select a new background color for a label control via the ColorDialog control.
They can pick any background color they like.
However, the label text color is Black, so certain background colors will make the label text illegible (as some would for any given text color.)
So, I would like to automatically change the color of the text to a legible color based on the user's background color choice to make it "impossible" to obscure the label text.

This is for a windows program, but I am going to use some formulas from the W3C that calculate the color and brightness contrast between two RGB color values.
(Source: http://www.w3.org/TR/2000/WD-AERT-20000426)
>>>>>>>>>>
Color brightness is determined by the following formula:
((Red value X 299) + (Green value X 587) + (Blue value X 114)) / 1000
Note: This algorithm is taken from a formula for converting RGB values to YIQ values. This brightness value gives a perceived brightness for a color.

Color difference is determined by the following formula:
(maximum (Red value 1, Red value 2) - minimum (Red value 1, Red value 2)) + (maximum (Green value 1, Green value 2) - minimum (Green value 1, Green value 2)) + (maximum (Blue value 1, Blue value 2) - minimum (Blue value 1, Blue value 2))
<<<<<<<<

According to their page, the color brightness difference should be about 125, the color difference should be about 500 so I will use their values.

Here's what I think I need to do:
1. Take the user's color selection from the ColorDialog control
2. If necessary, convert the color value from ColorDialog control to the appropriate type for the next step.
3. Break it into ARGB values
4. Use those values and the values for Black (label text color) in the formula
5. Make sure the brightness values differ by at least 125 and the color differences by at least 500.
6. Do any necessary color value or type conversions back to the right VB.net color type for the next step.
7. Set the label's text color to the new value.

I am getting stuck at 2. and 3 (which implies I will get stuck at 6.)

What "type" does the colordialog control return and what other type do I need to convert it to in order to get RBG values?

What generally do I need to know about VB.net color types?

Thank you.


0
Comment
Question by:bobinorlando
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 7

Accepted Solution

by:
dctuck earned 500 total points
ID: 18850591
The colordialog returns a Color type. You can then use:

colorDialog1.Color.R
colorDialog1.Color.G
colorDialog1.Color.B

to extract the R,G, Bvalues of the selected color returned by the ColorDialog
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question