WIC WINCODEC_ERR_BADHEADER仅用于JPEG图像 [英] WIC WINCODEC_ERR_BADHEADER only for JPEG images

查看:117
本文介绍了WIC WINCODEC_ERR_BADHEADER仅用于JPEG图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Windows Imaging Component API的简单编码/解码应用程序。我遇到的问题是,当我使用JPEGXR或BMP格式时,一切正常。但是,当我使用JPEG编解码器时-编码器工作正常,并且可以直观地验证生成的JPEG图像,但是当我尝试对该流进行解码时,我得到了WINCODEC_ERR_BADHEADER(0x88982f61)

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)

这是失败的行:

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

此处pInputStream是从字节数组创建的IStream(编码器的输出-输出的黑盒)字节向量)。

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

请帮助!

推荐答案

将流作为参数传递时,请确保将其预搜索到正确的初始位置(尤其是如果您只是将数据写入其中,并希望进一步进行检索,请找回它。通常不希望使用API​​,因为这样可以让您在更大的数据流中间提供数据。

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.

这篇关于WIC WINCODEC_ERR_BADHEADER仅用于JPEG图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆