728x90
반응형
728x170
using System;
#region 16진수 색상 코드 구하기 - GetHexadecimalColorCode(color)
/// <summary>
/// 16진수 색상 코드 구하기
/// </summary>
/// <param name="color">색상</param>
/// <returns>16진수 색상 코드</returns>
public string GetHexadecimalColorCode(Color color)
{
string red = "0" + string.Format("{0:x}", color.R);
string green = "0" + string.Format("{0:x}", color.G);
string blue = "0" + string.Format("{0:x}", color.B);
red = red.Substring (Math.Max(0, red.Length - 2), 2);
green = green.Substring(Math.Max(0, green.Length - 2), 2);
blue = blue.Substring (Math.Max(0, blue.Length - 2), 2);
return string.Format("{0}{1}{2}", red, green, blue);
}
#endregion
728x90
반응형
그리드형(광고전용)
'C# > WinForm' 카테고리의 다른 글
[C#/WINFORM] 사각형 그리기 (0) | 2015.02.01 |
---|---|
[C#/WINFORM] 사각형 칠하기 (0) | 2015.02.01 |
[C#/WINFORM] 원에서 특정 각도 포인트 구하기 (0) | 2015.01.31 |
[C#/WINFORM] 범위 색상 구하기 (0) | 2015.01.31 |
[C#/WINFORM] 비슷한 색상 구하기 (0) | 2015.01.31 |
[C#/WINFORM] 색상 정렬 리스트 구하기 (0) | 2015.01.31 |
[C#/WINFORM] RGB 구하기 (0) | 2015.01.31 |
[C#/WINFORM] BGRA 구하기 (0) | 2015.01.31 |
[C#/WINFORM] RGBA 구하기 (0) | 2015.01.31 |
[C#/WINFORM] 가장 가까운 색상 구하기 (0) | 2015.01.26 |
댓글을 달아 주세요