小编use*_*509的帖子

WPF 某些图像在加载时会旋转

我是 WPF 新手,找不到解决方法。我有一个在 XAML 中定义的基本图像控件。我正在将位图图像动态加载到此控件。问题是,当加载图像控件时,某些位图在图像控件中翻转,并且我想以其默认方向加载所有图像。

这是我的 XAML:

<StackPanel Width="Auto" DockPanel.Dock="Left" Margin="1,1,0,1" Orientation="Vertical" Background="{DynamicResource {x:Static SystemColors.GradientActiveCaptionBrushKey}}" HorizontalAlignment="Left" VerticalAlignment="Stretch" Height="Auto" >
   <Image x:Name="Photo"  Stretch="Uniform"  Height="149" Width="134" Margin="21,25,0,20" HorizontalAlignment="Left" VerticalAlignment="Top" />
</StackPanel>
Run Code Online (Sandbox Code Playgroud)

代码:

BitmapImage img = new BitmapImage();
img.BeginInit();
img.UriSource = new Uri(child.profilPoto.path, UriKind.Absolute);
img.EndInit();
Photo.Source = img;
Run Code Online (Sandbox Code Playgroud)

谢谢

编辑:

这是图像的链接:img左侧有一个如何在 WPF 中显示图像的信息。右侧是原始图像。

编辑2: 原始图像

已解决, 谢谢大家。这是元数据问题。我有很多照片的元数据很糟糕。当我尝试从其他相机加载图像时,一切正常。在某些编辑器中保存损坏的图像后,照片可以正确加载。

c# wpf xaml

4
推荐指数
1
解决办法
3260
查看次数

标签 统计

c# ×1

wpf ×1

xaml ×1