#region 改变图片颜色
/// <summary>
/// 改变图片的颜色
/// </summary>
/// <param name="filePath">图片的完整路径</param>
/// <param name="colorIndex">改变的颜色,true为灰色,false为彩色</param>
public void update_pixelColor(string filePath, bool colorIndex)
{
Bitmap bmp = new Bitmap(Bitmap.FromFile(filePath));
int value = 0;
for (int i = 0; i < bmp.Height; i++)
{
for (int j = 0; j < bmp.Width; j++)
{
if (colorIndex)
value = this.GetGrayNumColor(bmp.GetPixel(j, i));
else
value = this.GetHongNumColor(bmp.GetPixel(j, i));
bmp.SetPixel(j, i, Color.FromArgb(value, value, value));
}
}
bmp.Save(filePath);
}
/// <summary>
/// 获取彩色单点像素
/// </summary>
/// <param name="posClr">单点像素</param>
/// <returns>int</returns>
private int GetHongNumColor(Color posClr)
{
return (posClr.R * 19595 + posClr.G * 38469 + posClr.B * 7472) >> 16;
}
/// <summary>
/// 获取灰色单点像素
/// </summary>
/// <param name="posClr">单点像素</param>
/// <returns>Color</returns>
private int GetGrayNumColor(Color posClr)
{
//要改变ARGB
return (posClr.R * 19595 + posClr.G * 38469 + posClr.B * 7472) >> 16;
}
#endregion 改变图片颜色
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有