使用 PictureBox PictureBoxSizeMode.Zoom 时如何获得空白 space 大小

How to get blank space size when using PictureBoxSizeMode.Zoom of PictureBox

我在 Windows 表单中使用 PictureBox class。另外我将 PictureBox 的 SizeMode 设置为 PictureBoxSizeMode.Zoom.

如何计算这个黑色宽度添加到图片中的是什么?或者如何获得用于缩放此图片的比率?是否有一些现有的 属性 来获取图像的实际大小?

Is there some existing property to get real size of image?

PictureBox.Image.Size

How to calculate this black width what is added to the picture? Or how to get ratio what is used to scale this picture?

没有标准的方法可以做到这一点。但是你可以看看 http://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/PictureBox.cs,5c2ab37313f547c2 PictureBox 是如何在内部做到这一点的。