日期:2014-05-18 浏览次数:21253 次
string str = "110011101101001010110000";
int rgb = 0;
for (i = 0; i < 24; i++)
{
    if (str[i] == '1') rgb |= 1;
    rgb <<= 1;
}
Color color = Color.FromArgb(rgb);
------解决方案--------------------
string s = "110011101101001010110000";
           int r = Convert.ToInt32(s.Substring(0, 8),2);
           int g = Convert.ToInt32(s.Substring(8, 8),2);
           int b = Convert.ToInt32(s.Substring(16, 8),2);
           Color c = Color.FromArgb(r, g, b);
------解决方案--------------------
            string now = "110011101101001010110000";
            Regex reg = new Regex(@"\d{8}");
            MatchCollection coll = reg.Matches(now);
            int Red = Convert.ToInt32(coll[0].Value,2);
            int Green = Convert.ToInt32(coll[1].Value,2);
            int Blue = Convert.ToInt32(coll[2].Value, 2);         
            Color color = Color.FromArgb(Red,Green , Blue);
------解决方案--------------------
            string str = "110011101101001010110000";
            int tmp = Convert.ToInt32(str, 2);
            int red = tmp >> 16;
            int green = tmp >> 8 & 255;
            int blue = tmp & 255;
            Color color = Color.FromArgb(red, green, blue);