Solved

Convert ColorDialog control colors to ARGB and color type questions

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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