use*_*329 5 image windows-phone-8
这是我的代码...
public async Task SetLargeImageAsync(byte[] imageBytes,
bool storeBytesInObject = false)
{
var tcs = new TaskCompletionSource<string>();
SmartDispatcher.BeginInvoke(() =>
{
using (MemoryStream ms = new MemoryStream(imageBytes))
{
if (storeBytesInObject)
this.LargeImageBytes = imageBytes;
BitmapImage image = new BitmapImage();
image.SetSource(ms);
this.LargeImage = image;
tcs.SetResult(string.Empty);
}
});
await tcs.Task;
}
Run Code Online (Sandbox Code Playgroud)
我正在将字节发送到流中。这很好用;它正在显示图像。
但有时我会收到以下异常:
无法识别图像标题。(来自 HRESULT 的异常:0x88982F61)在 MS.Internal.XcpImports.CheckHResult(UInt32 hr) 在 MS.Internal.XcpImports.BitmapSource_SetSource(BitmapSource bitmapSource, CValue& byteStream) 在 System.Windows.Media.Imaging.BitmapSource.SetSourceInternal(Stream)在 System.Windows.Media.Imaging.BitmapImage.SetSourceInternal(Stream streamSource) 在 System.Windows.Media.Imaging.BitmapSource.SetSource(Stream streamSource)
问题是什么?不同类型的图像有什么问题吗?
我在某处发现我们应该使用以下代码来寻找开始位置:
ms.Seek(0, SeekOrigin.Begin)
Run Code Online (Sandbox Code Playgroud)
这是真的吗?什么是解决方案?
小智 3
您传递的图像无效 - 它已损坏或以 WP 无法本地解码的格式存储。支持格式的完整列表可以在以下位置找到:http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff462087 (v=vs.105).aspx#BKMK_ImageSupport