图片高保真缩放
我现在 用的是这个
nowImg = new Bitmap(canvas);
graphics = Graphics.FromImage(nowImg);
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;//让画线平滑
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.CompositingQuality = CompositingQuality.HighQuality;
orignalImg = Image.FromFile(way);
graphics.DrawImage(orignalImg, new Rectangle(50, 50, 325, 325));
nowImg.Save(str, System.Drawing.Imaging.ImageFormat.Jpeg);
canvas是一个400*400的白色图片
原始图片 way 是一个 180k的 1000*1000的图片 现在缩放到 300*300放在400*400背景中
保存 后 只有10.5k 图片完全达不到要求
求更好的方法
------解决方案--------------------保存为bmp或者png,不要保存为Jpg的,jpg压缩的太厉害!
------解决方案--------------------/// <summary>
/// 为图片生成缩略图
/// </summary>
/// <param name="phyPath">原图片的路径</param>
/// <param name="width">缩略图宽</param>
/// <param name="height">缩略图高</param>
/// <returns></returns>
public void GetThumbnail(string phyPath, int width, int height)
{
System.Drawing.Image image = System.Drawing.Image.FromFile(phyPath);
string folder = Path.GetDirectoryName(phyPath);
string dest1 = "\\s_" + Path.GetFileName(phyPath);