【发布时间】:2015-12-31 21:38:21
【问题描述】:
我正在使用 WinForms。在我的表格中,我有一个picturebox。它的 sizemode 设置为Zoom。如果我将图像加载到picturebox 中,图像将根据picturebox 尺寸进行缩放。
我想知道如何在picturebox 中获取缩放图像的大小。
这些是我尝试过的一些事情,但这并没有给我想要的结果。
private void Debug_Write_Click(object sender, EventArgs e)
{
//var pictureWidth = pictureBox1.ClientSize.Width; //This gives the size of the picturebox
//var picturewidth1 = pictureBox1.Image.Width; This gives the actual size of the image
//var pictureHight = pictureBox1.ClientSize.Height; //This gives the size of the picturebox
//var pictureHight1 = pictureBox1.ClientSize.Height; This gives the actual size of the image
Debug.WriteLine("Width: " + pictureWidth.ToString() + " Height: " + pictureHight.ToString());
}
Picturebox 尺寸模式设置为Zoom,因此它根据我的picturebox 尺寸缩放图像:
我如何找出这张图片的缩放长度和宽度?
【问题讨论】:
-
图片框内缩放图像的大小是什么意思?图片的实际尺寸?
-
例如,假设我的
picturebox长度:1000 和宽度是 500,我的图像长度:2000 和宽度:1000。当图像加载到picturebox时,它将重新相应地调整自己的大小。我想知道如何找到已重新调整大小以适合picturebox的图像的长度和宽度。 @dotctor -
Zoom 会保留图像的纵横比,因此您必须对使用的 最大 尺寸(宽度或高度)进行一些计算,然后相应地计算其他数字.
标签: c# .net image winforms picturebox