void CBRAnyChatSDKDemoDlg::DrawUserVideo(DWORD dwUserid, LPVOID lpBuf, DWORD dwLen, BITMAPINFOHEADER bmiHeader) { // 根據(jù)用戶ID號找到合適的顯示區(qū)域 DWORD dwSite = -1; for(INT i=0; i<DEMO_SHOW_USER_NUM; i++) { if(m_iUserID[i] == (INT)dwUserid) { dwSite = i; break; } } //沒有找到顯示區(qū)域就退出 if(dwSite == -1) return; CRect dispRect = m_UserRect[dwSite]; //構(gòu)建Bitmap BITMAPINFOHEADER *lpbmi = (BITMAPINFOHEADER*)malloc(sizeof(BITMAPINFOHEADER)+dwLen); ZeroMemory(lpbmi,sizeof(BITMAPINFOHEADER)+dwLen); memcpy((LPBYTE)lpbmi,&bmiHeader,sizeof(bmiHeader)); memcpy(((LPBYTE)lpbmi+sizeof(BITMAPINFOHEADER)),lpBuf,dwLen); HDC hdc = ::GetDC(m_hWnd); HDC dcMem = ::CreateCompatibleDC(hdc); HBITMAP hBitmap = CreateDIBitmap(hdc,lpbmi,CBM_INIT,(LPBYTE)lpbmi+sizeof(BITMAPINFOHEADER),(LPBITMAPINFO)lpbmi,DIB_RGB_COLORS); //繪圖 HBITMAP holdbm = (HBITMAP)SelectObject(dcMem,hBitmap); ::SetStretchBltMode(hdc,COLORONCOLOR); ::StretchBlt(hdc,dispRect.left,dispRect.top,dispRect.Width(),dispRect.Height(),dcMem,0,0,bmiHeader.biWidth,bmiHeader.biHeight,SRCCOPY); SelectObject(dcMem,holdbm); ::DeleteDC(dcMem); ::DeleteObject(hBitmap); ::ReleaseDC(m_hWnd,hdc); free(lpbmi); lpbmi = NULL; } |
|