HDC hdc;
PAINTSTRUCT ps;
IImage * m_pImage;
IImagingFactory * m_pImagingFactory;
//HDC hdc = dc.m_hDC;
CRect rcWnd;
GetWindowRect(&rcWnd);
hdc = ::BeginPaint(m_hWnd, &ps);
HRESULT hr;
//COM初始化
if (FAILED(hr = CoInitializeEx(NULL, COINIT_MULTITHREADED)))
{
goto END;
}
//创建COM实例
if(FAILED(hr = CoCreateInstance(CLSID_ImagingFactory,NULL,CLSCTX_INPROC_SERVER,IID_IImagingFactory,(void**) &m_pImagingFactory)))
{
goto END;
//MessageBox(L"OK1");
}
//从文件中创建图片
if(FAILED(hr = m_pImagingFactory->CreateImageFromFile(TEXT("D:\\测试.bmp"), &m_pImage)))
{
goto END;
//MessageBox(L"OK2");
}
//绘制图片
if(FAILED(hr = m_pImage->Draw(hdc,&rcWnd,NULL)))
{
goto END;
//MessageBox(L"OK3");
}
END:
//释放资源
if(m_pImage != NULL)
{
m_pImage->Release();
m_pImage = NULL;
}
if(m_pImagingFactory != NULL)
{
m_pImagingFactory->Release();
m_pImagingFactory = NULL;
}
::EndPaint(m_hWnd, &ps);
CoUninitialize();
复制代码
最新修改如下, 可以帮我看下有错吗?
显示不了图片