FileInfo fi1 = new FileInfo(保存路径 + "s_cover.jpg");
FileStream fs1 = fi1.OpenRead();
System.Drawing.Image Img1 = System.Drawing.Image.FromStream(fs1);
Bitmap bmp = new Bitmap(Img1);//可以设定图片的大小
for (int X = 0; X < bmp.Width; X++)
{
for (int Y = 0; Y < bmp.Height; Y++)
{
Color rgb = bmp.GetPixel(X, Y);
byte bBlue = rgb.B;
byte bRed = rgb.R;
byte bGreen = rgb.G;
int color = (9798 * bRed + 19235 * bGreen + 3735 * bBlue) / 32768;
Color NewColor = Color.FromArgb(color, color, color);
bmp.SetPixel(X, Y, NewColor);
}
}
bmp.Save(保存路径 + "s_cover1.jpg", ImageFormat.Jpeg);
bmp.Dispose();
fs1.Dispose();
fs1.Close();