Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何获取有关 WPF<Image>元素的源图像的信息?
<Image>
我的<Image>元素将其 Source 绑定到 ImageSource 属性,该属性经常更改。在我后面的代码中,出于数学目的,我需要能够访问当前源图像文件的实际宽度(以常规像素为单位)。我的应用程序将对图像文件执行图像操作,因此此信息是必要的。
任何帮助表示赞赏。
我认为这可能对你有用:
BitmapSource sourceData = image.Source as BitmapSource; int width = sourceData.PixelWidth; int height = sourceData.PixelHeight;