问题
The above exception occurs at line await bitmapImage.SetSourceAsync(fileStream);
whenever I tried to retrieve image from local file.
This is the method I'm using for storing and retrieving the image file.
public async Task<BitmapImage> RetrieveImageFromFile(String fileName)
{
try
{
StorageFile localFile = await _storageFolder.GetFileAsync(fileName + "Img");
BitmapImage bitmapImage = new BitmapImage();
using (IRandomAccessStream fileStream = await localFile.OpenAsync(FileAccessMode.Read))
{
await bitmapImage.SetSourceAsync(fileStream);
}
return bitmapImage;
}
catch(Exception e)
{
return null;
}
}
public async void WriteImageToFile(string fileName, IRandomAccessStreamWithContentType stream )
{
StorageFile file = await _storageFolder.CreateFileAsync(fileName + "Img", CreationCollisionOption.ReplaceExisting);
Stream streamToSave = stream.AsStreamForWrite();
using (Stream fileStram = await file.OpenStreamForWriteAsync())
{
streamToSave.CopyTo(fileStram);
}
}
The input stream for the WriteImageToFile method is retrieved from contact.Thumbnail.OpenReadAsync() method
Any help ?
回答1:
Just turning my comment into an answer since it's been helping people:
The 0x88982f50 error is generally related to a failure to read/decode an image file correctly. Verify your file is formatted properly. Google 88982f50 to see dozens of potentially related fixes, all relating to image file I/O. I never did find a definitive source for the error but this turned out to be my problem as well... Bad file.
回答2:
Late answer but might save someone else from spending hours hunting this down...
Error code 0x88982f50 is WINCODEC_ERR_COMPONENTNOTFOUND, and it's the Windows Imaging Component's way of saying it can't decode an image file.
Most likely the file is corrupted, or the version of WIC installed in Windows doesn't include a codec needed to decode it.
Microsoft provides zero information about it.
来源:https://stackoverflow.com/questions/30273307/the-component-cannot-be-found-exception-from-hresult-0x88982f50