I can't get the RGB Values.
Im Using a ColorDialog1 , in Borland Builder 5.
a screen appears where you can choose from the colors
red = 0 to 255
green = 0 to 255
blue = 0 to 255
How to retrieve these values from the ColorDialog?
If you can't solve that problem, im also having something else
Edit1->Text = "Hello World";
if i want to seperate "Hello" + "World" from this string so i would get
Edit2->Text = "Hello";
Edit3->Text = "World";
How would i go about?
These seemingly easy tasks are in reality much harder then it seems -_-
Probably the very next page in the manual.
Having displayed the control, the next logical step would be how to get the answer back.
-sigh- although i expected an answer like that, it still hurts >.<
As said easier said then done, have a look again
To display this screen when we click a button i simply use.
It shows the screen that you see above.
In the Dialog you see 3 rgb values, respectivly
R = 0
G = 255
B = 0
How do i retrieve the 3 individual R G B values.? (seriously i checked the manual and the internet a couple of times)
Your image is not visible...
Have you looked in the Web: http://www.functionx.com/bcb/applica...orselector.htm
About splitting string in the tokens - you can use stringstream for example
Sorry for the imagine not being visible, the page died on me, anyway i managed to fix the problem myself into obtaining the RGB values from a random given color.
Although simple it was a lot trickier then i expected to obtain the 3 values as i had to figure out how they designed the color scheme and appointed colours on the coordinates. I didn't want to create an entire new Colordialog from scratch,just get the rgb from the value given. It was tricky to see how much portion of every given primairy color was appointed to each color coordinate. Thanks so much for the time you've people decidate on helping people.
void __fastcall TForm1::Button1Click(TObject *Sender)
CSpinEdit1->Value = ColorDialog1->Color;
Memo1->Color = CSpinEdit1->Value;
CSpinEdit2->Value = CSpinEdit1->Value;
CSpinEdit3->Value = CSpinEdit1->Value/256;
CSpinEdit4->Value = CSpinEdit1->Value/256/256;
if(CSpinEdit2->Value > 255)
CSpinEdit6->Value = CSpinEdit3->Value * 256;
CSpinEdit2->Value = CSpinEdit1->Value - CSpinEdit6->Value;
if(CSpinEdit3->Value > 255 < 65280 )
CSpinEdit3->Value = CSpinEdit3->Value - CSpinEdit2->Value/256;
if(CSpinEdit1->Value >= 65280)
CSpinEdit5->Value = CSpinEdit4->Value * 256 * 256 + CSpinEdit2->Value;
CSpinEdit3->Value = CSpinEdit1->Value - CSpinEdit5->Value;
CSpinEdit3->Value = CSpinEdit3->Value/256;
http://uploader.ws/upload/200705/raw_example.jpg A very rough example on how to retrieve the RGB values from any given random colour.
roughly explained basically its a multiplication
256 for red
256*256 for Green
256*256*256 for blue
From there i did this crazy division and it somehow worked out lol.
So basically you wanted something like
R = CSpinEdit1->Value & 0xFF;
G = ( CSpinEdit1->Value >> 8 ) & 0xFF;
B = ( CSpinEdit1->Value >> 16 ) & 0xFF;
Going the other way
CSpinEdit1->Value = ( B << 16 ) | ( G << 8 ) | R;