【发布时间】:2011-04-15 22:09:16
【问题描述】:
为什么当由于 image.jpg 具有无效的元数据标头而发生 ArgumentException 时,第一个示例会捕获异常,而第二个示例没有?
示例 1:
try
{
Uri myUri = new Uri("http://example.com/image.jpg", UriKind.RelativeOrAbsolute);
JpegBitmapDecoder decoder2 = new JpegBitmapDecoder(myUri,
BitmapCreateOptions.PreservePixelFormat,
BitmapCacheOption.Default);
BitmapSource bitmapSource2 = decoder2.Frames[0];
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
示例 2:
try
{
BitmapImage src = new BitmapImage();
src.BeginInit();
src.UriSource = new Uri("http://example.com/image.jpg");
src.EndInit();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
【问题讨论】:
标签: c# wpf bitmapimage bitmapsource argumentexception