No automatic WIC decoder for JPG files?
-
Thursday, April 12, 2012 12:54 PM
Trying to decode a file from memory using WIC, the following code works for both PNG and TIFF but fails when trying to decode JPEG data:
Microsoft::WRL::ComPtr<IWICBitmapDecoder> decoder; wicFactory->CreateDecoderFromStream(fileContentsStream, nullptr, WICDecodeMetadataCacheOnDemand, &decoder);In the debug window the following message appears:
First-chance exception at 0x000007F84F198FDA (KernelBase.dll) in WWAHost.exe: 0xC0000002: The requested operation is not implemented.
According to the documentation, JPEG should be supported just fine. Any tips?
Edit: the returned HRESULT is 0x88982f61 saying "The image header is unrecognized". So I tried a couple of other JPG files and created some myself, but no dice.
Edit: trying to create a JPEG decoder using CreateDecoder and CLSID_WICJpegDecoder, the HRESULT is 0x88982f50 "The component cannot be found."
- Edited by Marcus Ilgner Thursday, April 12, 2012 4:25 PM
- Edited by Marcus Ilgner Thursday, April 12, 2012 4:33 PM
- Moved by Steve HorneMicrosoft Employee Monday, April 16, 2012 10:24 PM Not a Metro-style API (From:Building Metro style apps with C++ )
All Replies
-
Friday, April 13, 2012 8:34 AM
Hello,
Would you please provide us the whole project to reproduce this issue?
You can upload your project to skydriver
http://skydrive.live.com/
Best regards,
JesseJesse Jiang [MSFT]
MSDN Community Support | Feedback to us
-
Friday, April 13, 2012 7:31 PM
Unfortunalety, the project is quite complex with references to external libraries.
I was however able to isolate the problem to these few lines which succeed in a new testing project (both Blank Metro Application and Win32 Console), but still fail in my component project, saying "0x88982f50 : The component cannot be found."
Microsoft::WRL::ComPtr<IWICImagingFactory2> wicFactory; HRESULT res = CoCreateInstance( CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&wicFactory) ); Microsoft::WRL::ComPtr<IWICBitmapDecoder> decoder; res = wicFactory->CreateDecoder(CLSID_WICJpegDecoder, 0, &decoder);
The issue looks stranger and stranger by the minute.
-
Monday, April 16, 2012 9:39 AMHello,
Thanks for your feedback, I can reproduce this issue. I will involve more experts to investigate it.
Best regards,
JesseJesse Jiang [MSFT]
MSDN Community Support | Feedback to us
-
Tuesday, June 05, 2012 1:59 PM
Hi Jesse,
just an update from my side: I just tried this again with the Windows 8 Release Candidate, still the same problem persists.
Do you have any news on this issue?
All the best
Marcus
-
Wednesday, June 06, 2012 12:18 AMI don't know why CreateDecoderFromStream isn't working for you, but your use of CreateDecoder is incorrect. CreateDecoder expects a container format, e.g. GUID_ContainerFormatJpeg, not a CLSID. To create an instance of the jpeg decoder by CLSID, use CoCreateInstance.
-
Wednesday, June 06, 2012 10:36 AM@Vincent: Its not working on Windows 8 Release Preview. The usage of the API seems correct to me, the same code works when you compile and run the project not as Metro app but as Desktop app.
-
Wednesday, June 06, 2012 4:32 PMI'm no WIC expert, but I tried to find out why CreateDecoderFromStream isn't working with JPEG but running fine with other image formats. So I did some testing and found these lines of code that work with Non-Metro-Style apps but fail with Metro-Style Apps - and since it's on the same system, I don't think that CLSID/GUID mismatch is to blame.
-
Wednesday, June 13, 2012 11:22 AMAnother update: CreateDecoderFromFilename works with JPEG files, too.
-
Wednesday, August 08, 2012 6:03 PMOwner
Hello,
We demonstrate how to decode an image using WIC in a Metro style application in several SDK samples. For example, see the PhotoAdjustment sample:
http://code.msdn.microsoft.com/windowsapps/Direct2D-Image-Effects-2979be08
The error 0x88982f61 typically indicates that the image you are trying to decode is corrupt or is otherwise not recognized as valid by the WIC decoder. Does this image open in other programs? Can you share the image in question?
As Vincenr Povirk says, your usage of CreateDecoder is incorrect. You need to provide the JPEG container GUID (GUID_ContainerFormatJpeg), and WIC will select the best codec implementation that fits the criteria. Typically the only JPEG decoder is the Windows provided one and you will receive the implementation corresponding to CLSID_WICJpegDecoder.
This posting is provided "AS IS" with no warranties, and confers no rights. You assume all risk for your use.
© Microsoft Corporation. All rights reserved. -
Thursday, August 09, 2012 4:30 PM
Hello Simon,
I have tried a couple of different approaches but, as also commented by phil_ke, it comes down to the fact that this snippet works when compiled as Desktop app but doesn't when used in a Metro app. Also, replacing CreateDecoderFromStream with CreateDecoderFromFilename (which, judging by the name, should only differ in how they acquire the data), makes it work in a Metro app, too.
All the best
Marcus -
Thursday, August 09, 2012 7:44 PMCan you try using GUID_ContainerFormatJpeg instead of CLSID_WICJpegDecoder?


