3.在类CPng_ce_TestDlg加入参数
IImage *pImage;
IImagingFactory *m_pImageFactory;
4.在文件Png_ce_TestDlg.cpp的OnInitDialog()函数加入代码
CoInitializeEx(NULL ,COINIT_MULTITHREADED);
if(FAILED(CoCreateInstance(CLSID_ImagingFactory,NULL,CLSCTX_INPROC_SERVER,IID_IImagingFactory ,(void **) &m_pImageFactory)))
{
MessageBox(_T("CoCreateInstance Error"));
}
if(!SUCCEEDED(m_pImageFactory->CreateImageFromFile(_T("//ResidentFlash//car.png"),&pImage)))
{
MessageBox(_T("CreateImageFromFile Error"));
}
5.在OnPaint()函数加入代码
if(pImage!=NULL)
{
pImage->Draw(this->GetDC()->m_hDC ,CRect(0,0,214,408) ,NULL);
}
上述代码已经在VS2005+WinCE5.0通过
当要将两幅图片合成一幅图片显示时要特别注意 pImage->Draw中的CRECT参数,CRECT(left,top,right,bottom).