/// <summary> /// 按照比例缩放图片 /// </summary> /// <param name="bmp">原始Bitmap</param> /// <param name="Mode">比例</param> /// <returns>处理以后的图片</returns> public static Bitmap KiResizeImage(Bitmap bmp, float Mode) { try { int newW = Convert.ToInt32(bmp.Width * Mode); int newH = Convert.ToInt32(bmp.Height * Mode); Bitmap b = new Bitmap(newW, newH); Graphics g = Graphics.FromImage(b); // 插值算法的质量 g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.DrawImage(bmp, new Rectangle(0, 0, newW, newH), new Rectangle(0, 0, bmp.Width, bmp.Height), GraphicsUnit.Pixel); g.Dispose(); return b; } catch { return null; } }
文章评论