本文整理汇总了C++中IWICFormatConverter::CanConvert方法的典型用法代码示例。如果您正苦于以下问题:C++ IWICFormatConverter::CanConvert方法的具体用法?C++ IWICFormatConverter::CanConvert怎么用?C++ IWICFormatConverter::CanConvert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWICFormatConverter
的用法示例。
在下文中一共展示了IWICFormatConverter::CanConvert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertFormatIfRequired
HRESULT WICImageLoader::convertFormatIfRequired(IWICBitmapFrameDecode* pFrame, IWICFormatConverter** ppConv)
{
*ppConv = NULL;
if( (memcmp(&_format, &GUID_WICPixelFormat8bppGray, sizeof(WICPixelFormatGUID)) == 0) ||
(memcmp(&_format, &GUID_WICPixelFormat8bppAlpha, sizeof(WICPixelFormatGUID)) == 0) ||
(memcmp(&_format, &GUID_WICPixelFormat24bppRGB, sizeof(WICPixelFormatGUID)) == 0) ||
(memcmp(&_format, &GUID_WICPixelFormat32bppRGBA, sizeof(WICPixelFormatGUID)) == 0))
{
return S_OK;
}
HRESULT hr = E_FAIL;
IWICImagingFactory* pFactory = getWICFactory();
IWICFormatConverter* pConv = NULL;
if(NULL != pFactory)
{
hr = pFactory->CreateFormatConverter(&pConv);
}
WICPixelFormatGUID destFormat = GUID_WICPixelFormat32bppRGBA; // Fallback to RGBA 32-bit format which is supported by all devices
for( size_t i=0; i < _countof(g_WICConvert); ++i )
{
if ( memcmp( &g_WICConvert[i].source, &_format, sizeof(WICPixelFormatGUID) ) == 0 )
{
memcpy( &destFormat, &g_WICConvert[i].target, sizeof(WICPixelFormatGUID) );
break;
}
}
BOOL bCanConv = FALSE;
if(SUCCEEDED(hr))
{
hr = pConv->CanConvert(_format, destFormat, &bCanConv);
}
if(SUCCEEDED(hr) && bCanConv == TRUE)
{
hr = pConv->Initialize(pFrame, destFormat, WICBitmapDitherTypeErrorDiffusion, 0, 0, WICBitmapPaletteTypeCustom);
}
if(SUCCEEDED(hr))
{
memcpy(&_format, &destFormat, sizeof(WICPixelFormatGUID));
*ppConv = pConv;
}
return SUCCEEDED(hr);
}