关于BitmapImage EndInit()时报值不在范围内的异常

 值不在预期的范围内。ArgumentException   在 System.Windows.Media.ColorContext.GetColorContextsHelper(GetColorContextsDelegate getColorContexts)
   在 System.Windows.Media.Imaging.BitmapFrameDecode.get_ColorContexts()
   在 System.Windows.Media.Imaging.BitmapImage.FinalizeCreation()
   在 System.Windows.Media.Imaging.BitmapImage.EndInit()

查看最上层错误为System.Windows.Media.ColorContext.GetColorContextsHelper 猜想可能是因为图像文件元数据已损坏 或者该操作系统无法给予解析(测试的时候我自己的win10 可以正常解析 到了win7上就会报该错误)

处理方法:

BitmapImage 的 CreateOptions="IgnoreColorProfile" 忽略颜色配置文件
原文地址:https://www.cnblogs.com/dongzhaosheng/p/9523427.html