积极答复者
定点放大缩小图片思路或代码

问题
答案
-
使用两种方式都可以的,建议最好使用DrawImage的方式来实现,具体代码可以参考这个博客:
http://www.cnblogs.com/fengzhifengyi/archive/2011/05/12/2044224.html
/// <summary> /// 放大缩小图片尺寸 /// </summary> /// <param name="picPath"></param> /// <param name="reSizePicPath"></param> /// <param name="iSize"></param> /// <param name="format"></param> public void PicSized(string picPath, string reSizePicPath, int iSize, ImageFormat format) { Bitmap originBmp = new Bitmap(picPath); int w = originBmp.Width * iSize; int h = originBmp.Height * iSize; Bitmap resizedBmp = new Bitmap(w, h); Graphics g = Graphics.FromImage(resizedBmp); //设置高质量插值法 g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; //设置高质量,低速度呈现平滑程度 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; //消除锯齿 g.SmoothingMode = SmoothingMode.AntiAlias; g.DrawImage(originBmp, new Rectangle(0, 0, w, h), new Rectangle(0, 0, originBmp.Width, originBmp.Height), GraphicsUnit.Pixel); resizedBmp.Save(reSizePicPath, format); g.Dispose(); resizedBmp.Dispose(); originBmp.Dispose(); }
If my post is helpful,please help to vote as helpful, if my post solve your question, please help to make it as answer. my sample
- 已建议为答案 Learning hard 2013年6月12日 11:17
- 已标记为答案 Bob ShenModerator 2013年6月21日 8:47
全部回复
-
使用两种方式都可以的,建议最好使用DrawImage的方式来实现,具体代码可以参考这个博客:
http://www.cnblogs.com/fengzhifengyi/archive/2011/05/12/2044224.html
/// <summary> /// 放大缩小图片尺寸 /// </summary> /// <param name="picPath"></param> /// <param name="reSizePicPath"></param> /// <param name="iSize"></param> /// <param name="format"></param> public void PicSized(string picPath, string reSizePicPath, int iSize, ImageFormat format) { Bitmap originBmp = new Bitmap(picPath); int w = originBmp.Width * iSize; int h = originBmp.Height * iSize; Bitmap resizedBmp = new Bitmap(w, h); Graphics g = Graphics.FromImage(resizedBmp); //设置高质量插值法 g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; //设置高质量,低速度呈现平滑程度 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; //消除锯齿 g.SmoothingMode = SmoothingMode.AntiAlias; g.DrawImage(originBmp, new Rectangle(0, 0, w, h), new Rectangle(0, 0, originBmp.Width, originBmp.Height), GraphicsUnit.Pixel); resizedBmp.Save(reSizePicPath, format); g.Dispose(); resizedBmp.Dispose(); originBmp.Dispose(); }
If my post is helpful,please help to vote as helpful, if my post solve your question, please help to make it as answer. my sample
- 已建议为答案 Learning hard 2013年6月12日 11:17
- 已标记为答案 Bob ShenModerator 2013年6月21日 8:47