string filePath = Server.MapPath("~/...");//你的图片地址
Bitmap bmp = new Bitmap(filePath);
string htmlColor= "#"+Request.QueryString["color"];
Color newColor = System.Drawing.ColorTranslator.FromHtml(htmlColor);
///Old color
IntRange red= new IntRange(217,217);
IntRange green = new IntRange(20,20);
IntRange blue = new IntRange(31,31);
ColorFiltering colorFilter = new ColorFiltering(red, green, blue);
colorFilter.FillOutsideRange = false;//表示替换的是选中的颜色。如果false的话则表示替换外部的哪些颜色
colorFilter.FillColor = new AForge.Imaging.RGB(newColor);
Bitmap bitmap = colorFilter.Apply(bmp.Clone(new Rectangle(0,0,bmp.Width,bmp.Height) ,PixelFormat.Format24bppRgb));
Encoder enc = Encoder.Quality;
EncoderParameters eps = new EncoderParameters(1);
EncoderParameter ep = new EncoderParameter(enc, 90L);
eps.Param[0] = ep;
eps.Param[0] = ep;
ImageCodecInfo codecInfo = ImageCodecInfo.GetImageEncoders()[0];
bitmap.Save(Response.OutputStream,codecInfo,eps);
Response.ContentType = "image/jpeg";
Response.End();
图片高质量保存