Index R G B
0 0 0 255
1 0 69 255
2 0 135 255
3 0 204 255
4 0 255 237
5
...
14 255 69 0
15 255 0 0
9 个解决方案
#1
本来颜色就是用长整数(long)表示的。可以用宏
RGB(BYTE bRed, BYTE bGreen, BYTE bBlue) 来生成颜色值。
RGB(BYTE bRed, BYTE bGreen, BYTE bBlue) 来生成颜色值。
#2
嘻嘻。
#3
能不能建成自建的0~15的索引值呢?
#4
调色板?
#5
你具体是什么意思?
说清楚点吧
说清楚点吧
#6
就是用0~15的数字分别枚举上面的RGB组合成的颜色值
以后 0 就是指颜色 RGB(0,0,255)
1 --->RGB(0,69,255)
等等
以后 0 就是指颜色 RGB(0,0,255)
1 --->RGB(0,69,255)
等等
#7
gz
#8
可以呀。你可以用列表或数组来管理呀,下标就是你要的值嘛。
#9
用一个TComboBox
void __fastcall TForm1::ComboBox1DrawItem(TWinControl *Control, int Index,
TRect &Rect, TOwnerDrawState State)
{
TRect rect;
ComboBox1->Canvas->TextRect(Rect,Rect.Left+22,Rect.Top+1,ComboBox1->Items->Strings[Index]);
ComboBox1->Canvas->Pen->Color=clBlack;
ComboBox1->Canvas->Brush->Color=StringToColor(ComboBox1->Items->Strings[Index]);
ComboBox1->Canvas->Pen->Color=(TColor)((int)ComboBox1->Canvas->Brush->Color^0xffffff);
rect.Left=Rect.Left+1;
rect.Right=Rect.Left+16;
rect.Top=Rect.Top+1;
rect.Bottom=Rect.Bottom-1;
ComboBox1->Canvas->FillRect(rect);
ComboBox1->Canvas->Rectangle(rect.Left,rect.Top,rect.Right,rect.Bottom);
[Index]);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComboBox1MeasureItem(TWinControl *Control,
int Index, int &Height)
{
//Height=28;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComboBox1Change(TObject *Sender)
{
Panel1->Color=StringToColor(ComboBox1->Text);
/*switch(ComboBox1->ItemIndex)
{
case 0:
Panel1->Color=clRed;
break;
case 1:
Panel1->Color=clGreen;
break;
case 2:
Panel1->Color=clBlue;
break;
case 3:
Panel1->Color=clWhite;
break;
case 4:
Panel1->Color=clBlack;
break;
}*/
}
你也可以试着把数字放到ComboBox里面,然后把数字转换成TColor就OK了.
QQ:44514189
void __fastcall TForm1::ComboBox1DrawItem(TWinControl *Control, int Index,
TRect &Rect, TOwnerDrawState State)
{
TRect rect;
ComboBox1->Canvas->TextRect(Rect,Rect.Left+22,Rect.Top+1,ComboBox1->Items->Strings[Index]);
ComboBox1->Canvas->Pen->Color=clBlack;
ComboBox1->Canvas->Brush->Color=StringToColor(ComboBox1->Items->Strings[Index]);
ComboBox1->Canvas->Pen->Color=(TColor)((int)ComboBox1->Canvas->Brush->Color^0xffffff);
rect.Left=Rect.Left+1;
rect.Right=Rect.Left+16;
rect.Top=Rect.Top+1;
rect.Bottom=Rect.Bottom-1;
ComboBox1->Canvas->FillRect(rect);
ComboBox1->Canvas->Rectangle(rect.Left,rect.Top,rect.Right,rect.Bottom);
[Index]);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComboBox1MeasureItem(TWinControl *Control,
int Index, int &Height)
{
//Height=28;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComboBox1Change(TObject *Sender)
{
Panel1->Color=StringToColor(ComboBox1->Text);
/*switch(ComboBox1->ItemIndex)
{
case 0:
Panel1->Color=clRed;
break;
case 1:
Panel1->Color=clGreen;
break;
case 2:
Panel1->Color=clBlue;
break;
case 3:
Panel1->Color=clWhite;
break;
case 4:
Panel1->Color=clBlack;
break;
}*/
}
你也可以试着把数字放到ComboBox里面,然后把数字转换成TColor就OK了.
QQ:44514189
#1
本来颜色就是用长整数(long)表示的。可以用宏
RGB(BYTE bRed, BYTE bGreen, BYTE bBlue) 来生成颜色值。
RGB(BYTE bRed, BYTE bGreen, BYTE bBlue) 来生成颜色值。
#2
嘻嘻。
#3
能不能建成自建的0~15的索引值呢?
#4
调色板?
#5
你具体是什么意思?
说清楚点吧
说清楚点吧
#6
就是用0~15的数字分别枚举上面的RGB组合成的颜色值
以后 0 就是指颜色 RGB(0,0,255)
1 --->RGB(0,69,255)
等等
以后 0 就是指颜色 RGB(0,0,255)
1 --->RGB(0,69,255)
等等
#7
gz
#8
可以呀。你可以用列表或数组来管理呀,下标就是你要的值嘛。
#9
用一个TComboBox
void __fastcall TForm1::ComboBox1DrawItem(TWinControl *Control, int Index,
TRect &Rect, TOwnerDrawState State)
{
TRect rect;
ComboBox1->Canvas->TextRect(Rect,Rect.Left+22,Rect.Top+1,ComboBox1->Items->Strings[Index]);
ComboBox1->Canvas->Pen->Color=clBlack;
ComboBox1->Canvas->Brush->Color=StringToColor(ComboBox1->Items->Strings[Index]);
ComboBox1->Canvas->Pen->Color=(TColor)((int)ComboBox1->Canvas->Brush->Color^0xffffff);
rect.Left=Rect.Left+1;
rect.Right=Rect.Left+16;
rect.Top=Rect.Top+1;
rect.Bottom=Rect.Bottom-1;
ComboBox1->Canvas->FillRect(rect);
ComboBox1->Canvas->Rectangle(rect.Left,rect.Top,rect.Right,rect.Bottom);
[Index]);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComboBox1MeasureItem(TWinControl *Control,
int Index, int &Height)
{
//Height=28;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComboBox1Change(TObject *Sender)
{
Panel1->Color=StringToColor(ComboBox1->Text);
/*switch(ComboBox1->ItemIndex)
{
case 0:
Panel1->Color=clRed;
break;
case 1:
Panel1->Color=clGreen;
break;
case 2:
Panel1->Color=clBlue;
break;
case 3:
Panel1->Color=clWhite;
break;
case 4:
Panel1->Color=clBlack;
break;
}*/
}
你也可以试着把数字放到ComboBox里面,然后把数字转换成TColor就OK了.
QQ:44514189
void __fastcall TForm1::ComboBox1DrawItem(TWinControl *Control, int Index,
TRect &Rect, TOwnerDrawState State)
{
TRect rect;
ComboBox1->Canvas->TextRect(Rect,Rect.Left+22,Rect.Top+1,ComboBox1->Items->Strings[Index]);
ComboBox1->Canvas->Pen->Color=clBlack;
ComboBox1->Canvas->Brush->Color=StringToColor(ComboBox1->Items->Strings[Index]);
ComboBox1->Canvas->Pen->Color=(TColor)((int)ComboBox1->Canvas->Brush->Color^0xffffff);
rect.Left=Rect.Left+1;
rect.Right=Rect.Left+16;
rect.Top=Rect.Top+1;
rect.Bottom=Rect.Bottom-1;
ComboBox1->Canvas->FillRect(rect);
ComboBox1->Canvas->Rectangle(rect.Left,rect.Top,rect.Right,rect.Bottom);
[Index]);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComboBox1MeasureItem(TWinControl *Control,
int Index, int &Height)
{
//Height=28;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComboBox1Change(TObject *Sender)
{
Panel1->Color=StringToColor(ComboBox1->Text);
/*switch(ComboBox1->ItemIndex)
{
case 0:
Panel1->Color=clRed;
break;
case 1:
Panel1->Color=clGreen;
break;
case 2:
Panel1->Color=clBlue;
break;
case 3:
Panel1->Color=clWhite;
break;
case 4:
Panel1->Color=clBlack;
break;
}*/
}
你也可以试着把数字放到ComboBox里面,然后把数字转换成TColor就OK了.
QQ:44514189