19,467
社区成员
发帖
与我相关
我的任务
分享//每帧的播放函数
bool CVideoDraw::displayVideoFrame(SFrameYUV *picture, int imgWidth, int imgHeight)
{
if ((0 == picture) || !mInitialized)
return false;
if (!createYuvOffscreen(imgWidth, imgHeight))
{
return false;
}
mDDrawSurfOffScreen->Lock(NULL, &mDDrawSurfDesc, DDLOCK_WAIT | DDLOCK_WRITEONLY, NULL);
fillOffscreenSurf(picture, imgWidth, imgHeight);
RECT srcRect;
RECT dstRect;
memset(&srcRect, 0, sizeof(RECT));
memset(&dstRect, 0, sizeof(RECT));
setDisplayRect(srcRect, dstRect, imgWidth, imgHeight);
mDDrawSurfOffScreen->Unlock(NULL);
mDDrawResult = mDDrawSurfPrimary->Blt(&dstRect, mDDrawSurfOffScreen, &srcRect, DDBLT_WAIT, NULL);
if (FAILED(mDDrawResult))
{
return false;
}
//以下为使用的双缓存, 为什么输出还有闪烁呢?
HDC dc = GetDC(mWndHandle);
HDC memDC = CreateCompatibleDC(dc);
HBITMAP hBitMap = CreateCompatibleBitmap(dc, 200, 40);
HBITMAP hOldBitMap = (HBITMAP)SelectObject(memDC, hBitMap);
SetBkMode(memDC, TRANSPARENT);
SetTextColor(memDC, RGB(255,0,0));
TextOut(memDC,5, 20,"test..................",20) ;
BitBlt(dc, 5, 20, 200, 40, memDC, 5, 20, SRCCOPY);
SelectObject(memDC, hOldBitMap);
DeleteObject(hBitMap);
DeleteDC(memDC);
ReleaseDC(mWndHandle, dc);
return true;
}// create the chart surface
lpDDS_Map =
DDLoadBitmap(lpDD, MAKEINTRESOURCE(IDB_MAP), 0, 0);
// get a device context for it. This also locks the surface.
lpDDS_Map->GetDC(&hdc);
// set transparent mode so text won’t wipe out whole rectangle
SetBkMode(hdc, TRANSPARENT);
// "create" (i.e. choose) the desired font
hFont = EzCreateFont(hdc, "Times New Roman", 150, 0, EZ_ATTR_ITALIC, 0);
// select it into the device context
SelectObject(hdc, hFont);
// write the text
TextOut(hdc, 50, 50, "Here be Whales", 14);
// delete the font object.
DeleteObject(SelectObject(hdc, GetStockObject(SYSTEM_FONT)));
// release the device context and unlock the surface
lpDDS_Map->ReleaseDC(hdc);