显示图片中CDC和HDC问题
(m_Pic.LoadPictureData(pBuffer, nSize));//接作调用函数读pBuffer的jpg数据准备显示 showimage();//显示图片 void Caccess_test_1Dlg::showimage()//显示图片 { CRect rect; GetDlgItem(IDC_STATIC_pic)->GetWindowRect(&rect);//将矩形窗口选中到picture空间里 //ScreenToClient(&rect); CWnd *pWnd = GetDlgItem(IDC_STATIC_pic);//获得Picture窗口句柄 pWnd->GetClientRect(&rect);//获得Picture窗口矩形区域 CDC *pDC = pWnd->GetDC(); //m_image.Draw(pDC->m_hDC, rect, Gdiplus::InterpolationModeNearestNeighbor); m_Pic.Show(pDC->m_hDC, rect); ReleaseDC(pDC); return; }
出错:
将:
m_Pic.Show(pDC->m_hDC, rect);
改为:
m_Pic.Show(pDC, rect);
success!
ζั͡ޓއ genji - 至此只为原地流浪.......