첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.

728x90
반응형
728x170
using System.Drawing;

#region 색상 구하기 - GetColor(foregroundColor, backgroundColor, opacity)

/// <summary>
/// 색상 구하기
/// </summary>
/// <param name="foregroundColor">전경색</param>
/// <param name="backgroundColor">배경색</param>
/// <param name="opacity">투명도</param>
/// <returns>색상</returns>
public Color GetColor(Color foregroundColor, Color backgroundColor, int opacity)
{
    Color opaqueForegroundColor = Color.FromArgb(255, foregroundColor);
    Color opaqueBackgroundColor = Color.FromArgb(255, backgroundColor);

    float opaqueForegroundColorRed   = opaqueForegroundColor.R;
    float opaqueForegroundColorGreen = opaqueForegroundColor.G;
    float opaqueForegroundColorBlue  = opaqueForegroundColor.B;

    float opaqueBackgroundColorRed   = opaqueBackgroundColor.R;
    float opaqueBackgroundColorGreen = opaqueBackgroundColor.G;
    float opaqueBackgroundColorBlue  = opaqueBackgroundColor.B;

    float red       = opaqueForegroundColorRed   * opacity / 255 + opaqueBackgroundColorRed   * ((float)(255 - opacity) / 255);
    byte  redByte   = (byte)red;
    float green     = opaqueForegroundColorGreen * opacity / 255 + opaqueBackgroundColorGreen * ((float)(255 - opacity) / 255);
    byte  greenByte = (byte)green;
    float blue      = opaqueForegroundColorBlue  * opacity / 255 + opaqueBackgroundColorBlue  * ((float)(255 - opacity) / 255);
    byte  blueByte  = (byte)blue;

    return Color.FromArgb(255, redByte, greenByte, blueByte);
}

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

댓글을 달아 주세요