如何获得调整大小的图像的大小?

问题描述 投票:0回答:1

在UWP中我有这个图像

<Image Source="{Binding Bitmap}" Stretch="Uniform"/>

我想在代码后面的Image元素中获得调整大小的Bitmap的大小,所以我有这个

Image img = ...;

var width = img.Width; // this gives size of Image element not the bitmap resized
                       // inside the Image.

因此原始位图的大小可能是1920x1080,但是图像元素大小是300x200,因此在给定Stretch=Uniform的情况下,其中的位图大小为300x112.5。我想得到300x112.5

c# image uwp bitmap image-size
1个回答
1
投票

使用ActualWidth / ActualHeight属性。

© www.soinside.com 2019 - 2024. All rights reserved.