|
从网络上接受到bmp图片数据,然后在界面上显示出该bmp.代码如下:
CBitmap bitmap;
char* pvData;
pvData = (char*)malloc(VideoIndex);
memcpy(pvData,Video_Data,VideoIndex);
//这个地方总是创建失败 Video_Width=176,Video_Height=144
if(bitmap.CreateBitmap(Video_Width,Video_Height,1,24,pvData) != NULL)
{
CInDoorCeDlg * pDlg;
pDlg = (CInDoorCeDlg*)pWnd;
//picturebox控件变量m_Pic
CDC* pDC = pDlg->m_Pic.GetDC();
CDC bitmapDC;
bitmapDC.CreateCompatibleDC(pDC);
CBitmap* pOldBitmap = bitmapDC.SelectObject(&bitmap);
pDC->BitBlt(0,0,Video_Width,Video_Height,&bitmapDC,0,0,SRCCOPY);
bitmapDC.SelectObject(pOldBitmap);
bitmap.DeleteObject();
}
else
{
TRACE(_T("bitmap创建失败 %d\n"),::GetLastError());
}
free(pvData);
bitmap.CreateBitmap总是创建失败,返回错误代码是87,该错误是参数错误,但是没看出哪个参数有问题
|
|