c#中的Picturebox并调整图像提取大小

时间:2014-04-12 09:10:57

标签: c# winforms

我现在在图片框中启用了调整大小模式(拉伸),当我提取图像时,它不像图片框那样提取相同大小的图像,而是采用原始图片大小...任何提取方法拉伸的图像。我更关心宽度和高度。

详细 Winform的 C# Visual Studio 2013

1 个答案:

答案 0 :(得分:1)

你可以试试这个:

        Bitmap result = new Bitmap(picturebox.width, pixturebox.height);
        using (Graphics g = Graphics.FromImage(result))
            g.DrawImage(original_image, 0, 0, picturebox.width, 
                        pixturebox.height);

您实际上是使用PictureBox的当前宽度和高度创建一个新的Bitmap。然后,您可以保存图像:

    result.Save(filename);
相关问题