첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170
using System.Drawing;
using System.Drawing.Imaging;

#region 비슷한 색상 구하기 - GetSimilarColor(colorPalette, color)

/// <summary>
/// 비슷한 색상 구하기
/// </summary>
/// <param name="colorPalette">색상 팔레트</param>
/// <param name="color">색상</param>
/// <returns>유사 색상</returns>
public byte GetSimilarColor(ColorPalette colorPalette, Color color)
{
    byte minimumDifference = byte.MaxValue;
    byte index             = 0;
    byte currentDifference;

    for(int i = 0; i < colorPalette.Entries.Length - 1; i++)
    {
        currentDifference = GetMaximumDifference(color, colorPalette.Entries[i]);

        if(currentDifference < minimumDifference)
        {
            minimumDifference = currentDifference;
            index             = (byte)i;
        }
    }

    return index;
}

#endregion
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요