本文整理汇总了C++中IWICBitmapFrameDecode::QueryInterface方法的典型用法代码示例。如果您正苦于以下问题:C++ IWICBitmapFrameDecode::QueryInterface方法的具体用法?C++ IWICBitmapFrameDecode::QueryInterface怎么用?C++ IWICBitmapFrameDecode::QueryInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWICBitmapFrameDecode
的用法示例。
在下文中一共展示了IWICBitmapFrameDecode::QueryInterface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadLocalPNG
HBITMAP LoadLocalPNG( const std::string& sPath, const RASize& sz )
{
SetCurrentDirectory( Widen( g_sHomeDir ).c_str() );
ASSERT( _FileExists( sPath ) );
if( !_FileExists( sPath ) )
{
RA_LOG( "File could not be found: %s\n", sPath.c_str() );
return nullptr;
}
HBITMAP hRetVal = nullptr;
// Step 2: Decode the source image to IWICBitmapSource
IWICBitmapDecoder* pDecoder = nullptr;
HRESULT hr = g_UserImageFactoryInst.m_pIWICFactory->CreateDecoderFromFilename( Widen( sPath ).c_str(), // Image to be decoded
nullptr, // Do not prefer a particular vendor
GENERIC_READ, // Desired read access to the file
WICDecodeMetadataCacheOnDemand, // Cache metadata when needed
&pDecoder ); // Pointer to the decoder
// Retrieve the first frame of the image from the decoder
IWICBitmapFrameDecode* pFrame = nullptr;
if( SUCCEEDED( hr ) )
hr = pDecoder->GetFrame( 0, &pFrame );
// Retrieve IWICBitmapSource from the frame
if( SUCCEEDED( hr ) )
{
SAFE_RELEASE( g_UserImageFactoryInst.m_pOriginalBitmapSource ); //##SD ???
pFrame->QueryInterface( IID_IWICBitmapSource, reinterpret_cast<void**>( &g_UserImageFactoryInst.m_pOriginalBitmapSource ) );
}
// Step 3: Scale the original IWICBitmapSource to the client rect size
// and convert the pixel format
IWICBitmapSource* pToRenderBitmapSource = nullptr;
if( SUCCEEDED( hr ) )
hr = ConvertBitmapSource( { 0, 0, sz.Width(), sz.Height() }, pToRenderBitmapSource );
// Step 4: Create a DIB from the converted IWICBitmapSource
if( SUCCEEDED( hr ) )
hr = UserImageFactory_CreateDIBSectionFromBitmapSource( pToRenderBitmapSource, hRetVal );
SAFE_RELEASE( pToRenderBitmapSource );
SAFE_RELEASE( pDecoder );
SAFE_RELEASE( pFrame );
SAFE_RELEASE( g_UserImageFactoryInst.m_pOriginalBitmapSource );
return hRetVal;
}