BYTE数组
wchlp 2009-12-07 05:30:59 在一个对话框的 opaint函数里 想放大显示bitmap,
其中 pParent->m_pImage就是用byte 数组保存 一个截屏位图的信息 BITMAPINFOHEADER bi,bi保存位图的信息。
CRect rect;
CPaintDC dc(this);
GetClientRect(rect);
CBitmap display; CDC * memdc=new CDC;
CDC *pDC = GetDC();
=====================================================================================
//把BYTE数组转成bitmap,pParent->m_pImage是一个BYTE数组指针
bool test=display.CreateBitmap(bi.biWidth,bi.biHeight,bi.biPlanes,bi.biBitCount,pParent->m_pImage);
//返回的 test 值 是true 是不是表示转换成功
memdc->CreateCompatibleDC(pDC);
memdc->SelectObject(&display);
dc.StretchBlt(0,0,rect.Width(),rect.Height(),memdc,0,0,bi.biWidth,bi.biHeight,SRCCOPY);//放大显示bitmap
/// 但是这里不显示。,对话框中没有图像被画出来
======================================================我改用
SetDIBitsToDevice(pDC->GetSafeHdc(),rect.left,rect.top,bi.biWidth,bi.biHeight,0,0,0,
bi.biHeight,pParent->m_pImage,(BITMAPINFO*)(&bi),DIB_RGB_COLORS);
则可以画出位图