static size_t wicBitsPerPixel( REFGUID targetGuid ) { IWICImagingFactory* pWIC = getWIC(); if ( !pWIC ) return 0; IWICComponentInfo *cinfo; if ( FAILED( pWIC->CreateComponentInfo( targetGuid, &cinfo ) ) ) return 0; WICComponentType type; if ( FAILED( cinfo->GetComponentType( &type ) ) ) return 0; if ( type != WICPixelFormat ) return 0; IWICPixelFormatInfo *pfinfo; if ( FAILED( cinfo->QueryInterface( __uuidof(IWICPixelFormatInfo), reinterpret_cast<void**>( &pfinfo ) ) ) ) return 0; UINT bpp; if ( FAILED( pfinfo->GetBitsPerPixel( &bpp ) ) ) return 0; return bpp; }
size_t WICImageLoader::getBitsPerPixel(WICPixelFormatGUID format) { HRESULT hr = E_FAIL; IWICImagingFactory* pfactory = getWICFactory(); IWICComponentInfo* pCInfo = NULL; if(pfactory != NULL) { hr = pfactory->CreateComponentInfo(format, &pCInfo); } WICComponentType cType; if(SUCCEEDED(hr)) { hr = pCInfo->GetComponentType(&cType); } IWICPixelFormatInfo* pPInfo = NULL; if(SUCCEEDED(hr) && cType == WICPixelFormat) { hr = pCInfo->QueryInterface(IID_IWICPixelFormatInfo, (void**)&pPInfo); } UINT bpp = 0; if(SUCCEEDED(hr)) { hr = pPInfo->GetBitsPerPixel(&bpp); } SafeRelease(&pCInfo); SafeRelease(&pPInfo); return bpp; }