我目前正在努力获得大小和重塑我的矩形到实际大小的图像(宽度和高度)。然而,当我使用Image.Height或Image.Width时,它总是0。启动程序时显示的图片占据了整个屏幕。
Uri imageUri = new Uri(FileListe[position]);
Image Bild = new Image();
Bild.Source = new BitmapImage(imageUri);
Interface.Width = Bild.Width;
Interface.Height = Bild.Height;
brush.ImageSource = new BitmapImage(imageUri);
Interface.Fill = brush;发布于 2022-11-09 13:36:57
您试过使用位图图像获取宽度和高度吗?
例如:
BitmapImage bitmapBild = new BitmapImage(imageUri);
Interface.Width = bitmapBild.Width;
Interface.Height = bitmapBild.Height;发布于 2022-11-09 13:46:56
使用WPF时,如果需要图像中的实际像素数,则需要使用PixelWidth和PixelHeight,因为宽度/高度是指控件的大小。
所以,请记住你所处的环境。BitmapImage与System.Drawing.Bitmap有很大不同。
https://stackoverflow.com/questions/74375624
复制相似问题