문제

I have a simple encoding/ decoding application using Windows Imaging Component API. The issue I'm having is that when I use either the JPEGXR or BMP formats, everything works fine. However, when I use the JPEG codec - the encoder works fine and I can visually verify the generated JPEG image, but when I try to decode that stream, I get a WINCODEC_ERR_BADHEADER (0x88982f61)

Here's the line that fails:

    hr = m_pFactory->CreateDecoderFromStream(
                                    pInputStream, 
                                    NULL,
                                    WICDecodeMetadataCacheOnDemand,
                                    &pDecoder);

Here pInputStream is an IStream created from a byte array (output of the encoder - a black box which outputs a byte vector).

Please help! This is driving me nuts!

도움이 되었습니까?

해결책

When passing stream as an argument, make sure to pre-seek it to proper initial position (esp. seek it back to the beginning if you just wrote data into it and expect further retrieval). APIs are typically not expected to seek, because this way they let you provide data in the middle of a bigger stream.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top