我需要将 rgb 转换为 YCBCR 像素格式。我用过WICConvertBitmapSource()
。我的源像素格式是GUID_WICPixelFormat24bppBGR
. 我想把它转换成GUID_WICPixelFormat16bppCbCr
当我试图将它传递给函数时,它返回 HRESULT 为 0x88982F50。如果我通过GUID_WICPixelFormat32bppBGRA
,函数不会返回错误
我的问题是
- 为什么我的转换失败
我应该如何正确地将 RGB 转换为 YCbCr
0x88982F50 实际上是什么意思
这就是我尝试的方式。
int mwic_bitmap_converter
(
REFWICPixelFormatGUID dstPixelFormt, /* [in] Pixel format to be converted */
IWICBitmapSource* piBitmapSource, /* [in] Image Data */
IWICBitmapSource** ppiBitmapDst /* [out]converted image data */
)
{
WICPixelFormatGUID srcPixelFormat = { 0 }; /* Pixel format of the source */
UINT iWidth = 0, iHeight = 0; /* Size of the source */
UINT cbStride; /* Stride of the bitmap */
UINT cbBufferSize; /* Size of the buffer */
float* pixels; /* Pixel buffer */
piBitmapSource->GetSize(&iWidth,&iHeight);
piBitmapSource->GetPixelFormat(&srcPixelFormat);
if (!IsEqualGUID(srcPixelFormat, dstPixelFormt))
{
//this line gives the error
hr = WICConvertBitmapSource(dstPixelFormt, piBitmapSource, ppiBitmapDst);
}
.
.
.
.
.
}