简体   繁体   English

WPF下载的图像似乎不起作用

[英]WPF downloaded images don't seem to work

This is a bit of an odd one... Certain images... Not sure what differentiates them yet (all .jpg files) don't seem to work in WPF... Until I open them in paint and resave (even without making any changes. Although I realise that resaving a jpg always changes it.) 这有点奇怪......某些图像......不确定它们之间的区别(所有.jpg文件)似乎在WPF中都不起作用......直到我在油漆中打开它们并重新保存(即使没有做任何改变。虽然我意识到重新开始jpg会改变它。)

A really simple XAML file with 一个非常简单的XAML文件

<Image Source="C:\Users\Bob\Desktop\ChromeTest.jpg" />

doesn't work (error message "Value does not fall within the expected range") on the file downloaded through chrome or IE... But works just fine on the file if I resave it... Am I missing something obvious here? 通过chrome或IE下载的文件不起作用(错误消息“值不在预期的范围内”)...但如果我重新保存它就可以在文件上正常工作......我错过了一些明显的东西吗?

(I also tried a few of the .NET methods and they all seem to come out with the same issue, one way or another.) (我也尝试了一些.NET方法,他们似乎都出现了同样的问题,无论如何。)

Thanks. 谢谢。

Not sure but got this link here which talks about bad jpg files with corrupt data ( corrupt color profile ). 不确定,但在这里得到这个链接,讨论坏的jpg文件与损坏的数据( corrupt color profile )。

It provides a workaround as well that setting CreateOptions to IgnoreColorProfile on image will work for those corrupt images. 它还提供了一种解决方法, CreateOptions图像上的CreateOptions设置为IgnoreColorProfile将适用于那些损坏的图像。

Try this for your image as well and see if problem gets resolved with that - 尝试将此作为您的图像,并查看问题是否得到解决 -

<Image>
  <Image.Source>
     <BitmapImage CreateOptions="IgnoreColorProfile" 
                  UriSource="C:\Users\Bob\Desktop\ChromeTest.jpg"/>
  </Image.Source>
</Image>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM