大家好,我现在希望用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
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
解决方案 »
- Waistcoat来一下,请教几个问题
- MFC dll的应用程序工具条提示
- CImage 和 Gdi+ Image 各自有缺点,使用哪一个比较好?
- 关于线程参数传递的问题。。
- ****************我这样能进公司吗(来者有分)*********************
- 请教:MFC中程序和剪贴板交互.希望能有源程序!
- NetMessageBufferSend发送出现乱码。。。(50分在线)
- 关于数据库的存取
- 哪里有编程用的AVI资源可下载
- 没有人知道吗?新建了一个窗格和一个FormView导致的问题
- Tab键最早是出现在什么地方的?他的规范性定义在哪能找到,我要最原始最权威的档案?兄弟姐妹帮忙啊!急!!!
- 如何用Windows API函数设置打印的方向
改成:
m_stcImageInput.ReleaseDC(pPicDC);
另外,最好是在响应控件的WM_PAINT消息时显示图象,以免被刷掉。
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、如一楼所说的错误要改!