quinta-feira, 12 de abril de 2012 12:54
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."
Todas as Respostas
sexta-feira, 13 de abril de 2012 08:34
sexta-feira, 13 de abril de 2012 19:31
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.
segunda-feira, 16 de abril de 2012 09:39Hello,
Thanks for your feedback, I can reproduce this issue. I will involve more experts to investigate it.
Jesse Jiang [MSFT]
MSDN Community Support | Feedback to us
terça-feira, 5 de junho de 2012 13:59
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
quarta-feira, 6 de junho de 2012 00:18I 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.
quarta-feira, 6 de junho de 2012 10:36@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.
quarta-feira, 6 de junho de 2012 16:32I'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.
quarta-feira, 13 de junho de 2012 11:22Another update: CreateDecoderFromFilename works with JPEG files, too.
quarta-feira, 8 de agosto de 2012 18:03Proprietário
We demonstrate how to decode an image using WIC in a Metro style application in several SDK samples. For example, see the PhotoAdjustment sample:
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.
quinta-feira, 9 de agosto de 2012 16:30
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
quinta-feira, 9 de agosto de 2012 19:44Can you try using GUID_ContainerFormatJpeg instead of CLSID_WICJpegDecoder?