日期:2014-05-17 浏览次数:21353 次
/// <summary>
/// 对颜色数组进行混合
/// </summary>
/// <param name="colors"></param>
/// <returns></returns>
public static Color BlendColor(Color[] colors)
{
if (colors.Length <= 0)
return Color.Transparent;
ulong asum = 0, rsum = 0, gsum = 0, bsum = 0;
for (int i = 0, len = colors.Length; i < len; i++)
{
asum += colors[i].A;
rsum += (ulong)(colors[i].A*colors[i].R);
gsum += (ulong)(colors[i].G*colors[i].A);
bsum += (ulong)(colors[i].B*colors[i].A);
}
if (asum == 0)
return Color.Transparent;
rsum /= asum;
gsum /= asum;
bsum /= asum;
asum /= (ulong)colors.Length;
return Color.FromArgb((int)asum, (int)rsum, (int)gsum, (int)bsum);
}
/// <summary>
/// 毛玻璃效果
/// </summary>
/// <param name="srcBmp">源图片</param>
/// <param name="minRadius">最小离散半径</param>
/// <param name="maxRadius">最大离散半径</param>
/// <param name="samples">采样点数</param>
/// <returns></returns>
public static Bitmap FrostedEffect(Bitmap srcBmp, int minRadius, int maxRadius, int samples)