我该如何调整图像大小?

时间:2013-05-13 20:21:56

标签: c#

我有这段代码:

public static Bitmap ResizeImage(Bitmap imgToResize, Size size)
        {
            try
            {
                Bitmap b = new Bitmap(size.Width, size.Height);
                using (Graphics g = Graphics.FromImage((Image)b))
                {
                    g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

                    g.DrawImage(imgToResize, 0, 0, size.Width, size.Height);
                }

                return b;
            }
            catch
            {
                throw;
            }
        }

当我调用该函数时,例如:ResizeImage(bmp, 我该如何设置尺寸?

1 个答案:

答案 0 :(得分:1)

例如

ResizeImage(bmp, new Size(150, 150));