我查了OLE_COLOR,也是32为的,说明如下: OLE_COLOR The OLE_COLOR data type is used for properties that return colors. When a property is declared as OLE_COLOR, the Properties window will display a color-picker dialog that allows the user to select the color for the property visually, rather than having to remember the numeric equivalent.An example of the use of OLE_COLOR can be found in "Exposing Properties of Constituent Controls."OLE_COLOR is treated internally as a Long.说说你想用它做什么,说不定换个方式也可以。
myColor.A:alpha
myColor.B:blue
myColor.G:green
myColor.R:red
Color.Red.A;
Color.Red.B;
Color.Red.G;
Color.Red.R;
uint BrushColor; //C#中应该这样定义,只是这同别人提供的ColorDialog MyDialog = new ColorDialog();
if (MyDialog.ShowDialog() == DialogResult.OK)
{
this.label1.BackColor = MyDialog.Color;
}
BrushColor = Fun(this.label1.BackColor);//转换函数
uint Fun(System.Drawing.Color color)
{
//如何写
}
brushColor=(uint)Color.Red.ToArgb();
myColor.B:blue
myColor.G:green
myColor.R:red
OLE_COLOR
The OLE_COLOR data type is used for properties that return colors. When a property is declared as OLE_COLOR, the Properties window will display a color-picker dialog that allows the user to select the color for the property visually, rather than having to remember the numeric equivalent.An example of the use of OLE_COLOR can be found in "Exposing Properties of Constituent Controls."OLE_COLOR is treated internally as a Long.说说你想用它做什么,说不定换个方式也可以。
uint To_OLEColor(System.Drawing.Color color)
{
//提取三原色值
return (uint)(color.B*65536 + color.G*256 + color.R);
}作用与System.Drawing.ColorTranslator.ToOle(color)是一样,怎么我找了半天就没找到这个函数呢?真是差劲,以后要好好学习,谢谢Knight94(愚翁)和hzg_yujia(雨佳)的真忱帮助。
System.Drawing.Color To_CSColor(uint color)
{
//转换成16进制
string s = System.Convert.ToString((int)color,16); int intR = 0;
int intG = 0;
int intB = 0; //视情况将三原色提取出来
if (s.Length <= 2)
{
intR = System.Convert.ToInt32(s,16);
intG = 0;
intB = 0;
}
else if (s.Length <= 4)
{
intR = System.Convert.ToInt32(s.Remove(0,s.Length-2),16);
intG = System.Convert.ToInt32(s.Remove(s.Length-2,2),16);
intB = 0;
}
else if (s.Length <=6)
{
intR = System.Convert.ToInt32(s.Remove(0,s.Length-2),16);
intG = System.Convert.ToInt32(s.Remove(0,s.Length-4).Remove(2,2),16);
intB = System.Convert.ToInt32(s.Remove(s.Length-4,4),16);
}
else
{
MessageBox.Show("转换颜色有错!");
} return System.Drawing.Color.FromArgb(255,intR,intG,intB);
}