Solved

Convert ColorDialog control colors to ARGB and color type questions

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now