大家好,我现在希望用cximage 将摄像头得到的图像显示指定的图片框中,源码如下, CRect rect;
CDC* pPicDC;
pPicDC = m_stcImageInput.GetDC();
m_stcImageInput.GetClientRect(rect); int index = 0;
COLORREF color = 0;
for (int i=0; i<m_iCameraWidth; i++)
for (int j=0; j<m_iCameraHeight; j++)
{
color = m_ucImageStore[0][index] + (m_ucImageStore[0][index] << 8) + (m_ucImageStore[0][index] << 16);
m_pcxImage->SetPixelColor(i, j, color);
index++;
}
m_pcxImage->Stretch((HDC) *pPicDC, rect);
pPicDC->DeleteDC();其中m_stcImageInput是被化的图片框,m_ucImageStore是图像数据,
图片框中显示不出图像,请问谁知道怎么解决这个问题,谢谢。
mwolf

解决方案 »

  1.   

    pPicDC->DeleteDC();
    改成:
    m_stcImageInput.ReleaseDC(pPicDC);
    另外,最好是在响应控件的WM_PAINT消息时显示图象,以免被刷掉。
      

  2.   

    估计被刷新掉了,放到WM_PAINT消息响应中。
      

  3.   

    1、将这个画图函数,放在ONPAIN里面调用
    2、保证m_ucImageStore里面数据正确
    3、color = m_ucImageStore[0][index] + (m_ucImageStore[0][index] < < 8) + (m_ucImageStore[0][index] < < 16); 中,m_ucImageStore是什么类型?是否要改成:color = RGB(m_ucImageStore[0][index], (m_ucImageStore[0][index] < < 8), (m_ucImageStore[0][index] < < 16)); ?
    4、如一楼所说的错误要改!