Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The component cannot be found. (Exception from HRESULT: 0x88982F50)

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 ?

like image 253
MohanRajNK Avatar asked May 16 '15 08:05

MohanRajNK


Video Answer


2 Answers

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.

like image 121
sraboy Avatar answered Oct 16 '22 14:10

sraboy


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.

like image 2
Ger O'Donnell Avatar answered Oct 16 '22 14:10

Ger O'Donnell