画Bits到DC上,HDC缓存

来源:互联网 发布:自动弹钢琴的软件 编辑:程序博客网 时间:2024/06/05 04:59

画Bits到DC上,HDC缓存

void DrawBits(HWND hWnd,BYTE* pBits){RECT rc;::GetClientRect(hWnd,&rc);int nWidth = rc.right - rc.left;int nHeight = rc.bottom - rc.top;HDC hDC         = ::GetDC(hWnd);HDC hMemDc      = ::CreateCompatibleDC(hDC);HBITMAP hBitmap = ::CreateCompatibleBitmap(hDC,nWidth,nHeight);BITMAPINFOHEADER bmiHeader = {sizeof(BITMAPINFOHEADER),nWidth,nHeight,1,32,BI_RGB,0,0,0,0};HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hMemDc,hBitmap);::SetStretchBltMode(hMemDc,COLORONCOLOR);::StretchDIBits(hMemDc,rc.left,rc.top,nWidth,nHeight, 0,0,nWidth,nHeight,pBits,(LPBITMAPINFO)&bmiHeader,DIB_RGB_COLORS,SRCCOPY);::SelectObject(hMemDc,hOldBitmap);::DeleteObject(hBitmap);::DeleteDC(hMemDc);::ReleaseDC(hWnd,hDC);}


0 0
原创粉丝点击