Solved

Convert ColorDialog control colors to ARGB and color type questions

Posted on 2007-04-04
1
463 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
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

785 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