C# 16진수 색상과 Color 객체 간 변환

1523 단어 C#
// color 
ColorTranslator.FromHtml("#FF0000")
  ColorTranslator.FromHtml("Red");

// color 
ColorTranslator.ToHtml(Color.FromArgb(255,255,255))
  ColorTranslator.ToHtml(Color.Red);

// 
Console.WriteLine(Convert.ToString(69, 2));
// 
Console.WriteLine(Convert.ToString(69, 8));
// 
Console.WriteLine(Convert.ToString(69, 16));
// 
Console.WriteLine(Convert.ToInt32(”100111101″, 2));
// 
Console.WriteLine(Convert.ToInt32(”76″, 8));
// 
Console.WriteLine(Convert.ToInt32(”FF”, 16));

string color_s = ColorTranslator.ToHtml(g.Pen.Color);
color_s = color_s.Substring(1, color_s.Length - 1);
g.Pen.Color = ColorTranslator.FromHtml("#"+Convert.ToString(Convert.ToInt32(color_s, 16)+40000, 16));
Color Color1 = System.Drawing.ColorTranslator.FromHtml( "#EEEEEE" ); Color Color2 = System.Drawing.ColorTranslator.FromHtml( "red" );     /* ** Convert back: */     string   Color1a = System.Drawing.ColorTranslator.ToHtml(Color1); // --> "#EEEEEE"     string   Color2a = System.Drawing.ColorTranslator.ToHtml(Color2); // --> "Red"     string   Color2b = String.Format( "#{0:X2}{1:X2}{2:X2}" , Color2.R, Color2.G, Color2.B);

좋은 웹페이지 즐겨찾기