[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Convert ColorDialog control colors to ARGB and color type questions

Posted on 2007-04-04
1
Medium Priority
?
525 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 1500 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

656 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