Solved

Get the RGB values from the custom color in visual studio

Posted on 2009-07-03
1
656 Views
Last Modified: 2012-05-07
Hi Experts,

I am running microsoft visual studio. I have a gui that prompts the user to select a custom color from the color dialog box.

Below is the code I have currently to get the hue, saturation, and luminosity.

Unfortunately, I cannot find a way to directly get the RGB values, which I would like to use instead of those values.
Can you please replace the snippet of code below with the code that would get teh RGB values.

THanks,

Dennis
#pragma endregion
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
 
				 this->colorDialog1->ShowDialog();
 
				 // Write the hue to the screen which is measured in degrees, ranging from 0.0 through 360.0, in HSB color space.
 
				 this->textBox1->Text = safe_cast<IConvertible ^>(colorDialog1->Color.GetHue())->ToString(nullptr);
 
				 // Write the brightness to the screen which ranges from 0.0 through 1.0, where 0.0 represents black and 1.0 represents white.
 
				 this->textBox6->Text = safe_cast<IConvertible ^>(colorDialog1->Color.GetBrightness())->ToString(nullptr);
 
				 // Write the saturation to the screen which ranges from 0.0 through 1.0, where 0.0 is grayscale and 1.0 is the most saturated.
 
				 this->textBox2->Text = safe_cast<IConvertible ^>(colorDialog1->Color.GetSaturation())->ToString(nullptr);
 
			 }

Open in new window

0
Comment
Question by:datopdogg7
[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 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 24770686
how about
colorDialog1->Color.R  for the red component, (G and B fror green and blue)
0

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

617 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