::CoInitialize(NULL); // COM
HRESULT hr;
CFile file;
file.Open( "c:\\aa.jpg", CFile::modeRead | CFile::shareDenyNone ); //
DWORD dwSize = file.GetLength();
HGLOBAL hMem = ::GlobalAlloc( GMEM_MOVEABLE, dwSize );
LPVOID lpBuf = ::GlobalLock( hMem );
file.Read( lpBuf, dwSize );
file.Close();
::GlobalUnlock( hMem );
IStream * pStream = NULL;
IPicture * pPicture = NULL;
// HGLOBAL IStream, TRUE IStream ,
hr = ::CreateStreamOnHGlobal( hMem, TRUE, &pStream );
ASSERT ( SUCCEEDED(hr) );
hr = ::OleLoadPicture( pStream, dwSize, TRUE, IID_IPicture, ( LPVOID * )&pPicture );
ASSERT(hr==S_OK);
long nWidth,nHeight; // ,MM_HIMETRIC , 0.01
pPicture->get_Width( &nWidth ); //
pPicture->get_Height( &nHeight ); //
//
//CSize sz( nWidth, nHeight );
//pDC->HIMETRICtoDP( &sz ); // MM_HIMETRIC MM_TEXT
//pPicture->Render(pDC->m_hDC,0,0,sz.cx,sz.cy,
// 0,nHeight,nWidth,-nHeight,NULL);
CRect rect; GetClientRect(&rect);
pPicture->Render(pDC->m_hDC,0,0,rect.Width(),rect.Height(),
0,nHeight,nWidth,-nHeight,NULL);
if ( pPicture ) pPicture->Release();// IPicture
if ( pStream ) pStream->Release(); // IStream , hMem
::CoUninitialize();