关于VNC里的录像问题

_拂晓 2012-05-09 03:17:02
求高手帮忙:
部分代码如下:(来自NVC mirror driver)


LPBITMAPINFOHEADER alpbi; //记录屏幕信息的位图,,,帧
alpbi=captureScreenFrame(left,top,width, height,1); //截取的屏幕 并已经封装成帧

if (flashingRect) { // Set Up Flashing Rect、、、这是干嘛用的没搞懂 求解释
pFrame->SetUpRegion(left,top,width,height,0);
pFrame->ShowWindow(SW_SHOW);
}
//然后就是AVI文件流压缩器的初始化。。。省略一大堆。。。
FreeFrame(alpbi);//刚才截取的那一帧 没用就释放了。。。。,难道是用于初始化AVI
alpbi=NULL;

//录像重这里真正的开始。。。。
while(1)
{
alpbi=captureScreenFrame(left,top,width, height,0);//最后一个参数变成了 0
hr = AVIStreamWrite(psCompressed, // stream pointer
frametime, // time of this frame
1, // number to write
(LPBYTE) alpbi + // pointer to data
alpbi->biSize +
alpbi->biClrUsed * sizeof(RGBQUAD),
alpbi->biSizeImage, // size of this frame
//AVIIF_KEYFRAME, // flags....
0, //Dependent n previous frame, not key frame
NULL,
NULL);
nActualFrame ++ ;//帧数 加1
InvalidateRect(NULL, NULL, FALSE);//声明客户区无效,重画时不擦除背景??
FreeFrame(alpbi);
alpbi=NULL;
Sleep(5);//
}




然后下面是captureScreenFrame的实现:
LPBITMAPINFOHEADER captureScreenFrame(int left,int top,int width, int height,int tempDisableRect)
{
HANDLE hdib ;
HDC hdc ;
BITMAP bitmap ;
UINT wLineLen ;
DWORD dwSize ;
DWORD wColSize ;
LPBITMAPINFOHEADER lpbi ;
LPBYTE lpBits ;

//tempDisableRect仅初始化AVI的时候为 1 , 录像阶段永远为 0 ,包挎第一帧
if (flashingRect && !tempDisableRect) {//???????????
DrawFlashingRect( TRUE , 0);

}

wLineLen = (width*bits+31)/32 * 4;//计算位图每行占多少个字节
wColSize = sizeof(RGBQUAD)*((bits <= 8) ? 1<<bits : 0);//0
dwSize = sizeof(BITMAPINFOHEADER) + wColSize +
(DWORD)(UINT)wLineLen*(DWORD)(UINT)height;

//
// Allocate room for a DIB and set the LPBI fields
hdib = GlobalAlloc(GHND,dwSize);
if (!hdib)
exit(1) ;

lpbi = (LPBITMAPINFOHEADER)GlobalLock(hdib) ;

lpbi->biSize = sizeof(BITMAPINFOHEADER) ;
lpbi->biWidth = width ;
lpbi->biHeight = height ;
lpbi->biPlanes = 1 ;//The number of planes for the target device. This value must be set to 1.
lpbi->biBitCount = (WORD) bits ;//灰度图像(biBitCount=8)彩色图像(biBitCount=24)
lpbi->biCompression = BI_RGB ;//BI_RGB An uncompressed format.
lpbi->biSizeImage = dwSize - sizeof(BITMAPINFOHEADER) - wColSize ;//位图所占字节
lpbi->biXPelsPerMeter = 0 ;
lpbi->biYPelsPerMeter = 0 ;
lpbi->biClrUsed = (bits <= 8) ? 1<<bits : 0;
lpbi->biClrImportant = 0 ;

//
// Get the bits from the bitmap and stuff them after the LPBI
lpBits = (LPBYTE)(lpbi+1)+wColSize ;


if (videodriver.myframebuffer)//设置像素,每一帧
SETPIXELS_NOCONV((BYTE *)videodriver.myframebuffer,lpBits, left, top, width, height,bits,maxxScreen);
GlobalUnlock(hdib);

LPBITMAPINFOHEADER pBM_HEADER = (LPBITMAPINFOHEADER)GlobalLock(hdib);//锁定一个全局内存对象并返回一个指向对象的内存块的第一个字节。
//LPBITMAPINFOHEADER pBM_HEADER = (LPBITMAPINFOHEADER)GlobalLock(Bitmap2Dib(hbm, 24));
if (pBM_HEADER == NULL) {

//MessageBox(NULL,"Error reading a frame!","Error",MB_OK | MB_ICONEXCLAMATION);
MessageOut(NULL,IDS_STRING_ERRFRAME ,IDS_STRING_NOTE,MB_OK | MB_ICONEXCLAMATION);

exit(1);
}
//if flashing rect
if (flashingRect && !tempDisableRect) {
DrawFlashingRect(FALSE , 0);
}

return pBM_HEADER;
}





void DrawFlashingRect(BOOL bDraw , int mode) {
if (mode == 1) {

pFrame->PaintInvertedBorder(RGB(0,255,80));//绘画倒转的边框,永不执行
}
else {

if (bDraw)
pFrame->PaintBorder(RGB(255,255,180));
else
pFrame->PaintBorder(RGB(0,255,80));
}
}






void CFlashingWnd::PaintBorder(COLORREF colorval)
{

// Add your drawing code here!
HDC hdc = ::GetDC(m_hWnd);
if ((cRect.right>cRect.left) && (cRect.bottom>cRect.top)) {

HBRUSH newbrush = (HBRUSH) CreateSolidBrush( colorval);
HBRUSH newpen = (HBRUSH) CreatePen(PS_SOLID,1, colorval);
HBRUSH oldbrush = (HBRUSH) SelectObject(hdc,newbrush);
HBRUSH oldpen = (HBRUSH) SelectObject(hdc,newpen);


Rectangle(hdc,cRect.left-THICKNESS,cRect.top-THICKNESS,cRect.right+THICKNESS,cRect.bottom+THICKNESS);

SelectObject(hdc,oldpen);
SelectObject(hdc,oldbrush);
DeleteObject(newpen);
DeleteObject(newbrush);

}

::ReleaseDC(m_hWnd,hdc);
}





我想请问大伙儿在captureScreenFrame中2次if语句是干嘛用的 谢谢
if (flashingRect && !tempDisableRect) {//???????????
DrawFlashingRect( TRUE , 0);

}
if (flashingRect && !tempDisableRect) {
DrawFlashingRect(FALSE , 0);
}

if (flashingRect) { // Set Up Flashing Rect、、、这是干嘛用的没搞懂 求解释
pFrame->SetUpRegion(left,top,width,height,0);
pFrame->ShowWindow(SW_SHOW);
}


原帖地址http://topic.csdn.net/u/20120509/13/282e8067-c135-4314-8d1e-cc0d7ada8ca8.html
...全文
201 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
s821416394 2012-05-10
  • 打赏
  • 举报
回复
没人自己顶
行动 基于centos6 + python3.6 + django2 + ansible2.4 + celery4.2运维管理系统-开发中,目前实现的功能:用户和用户组管理,日程管理,资产管理,集成ansible,简易堡垒机(主机分配(支持Linux和Windows),用户分配,文件上传下载,配置命令命令清单,操作录像回放功能),数据库管理(部分),CI / CD(支持git仓库和svn仓库),celery任务编排,基于markdown编辑器的出版物支持实时预览和分级搜索结果高亮和文件共享中心 4.24更新 资产管理添加了阿云主机自动拉取入库功能,像其他腾讯云,华为云等实现方法都差不多就没一一实现,本来想写一些关于docker管理的东西,但感觉没什么实际应用场景,现在k8s编排这么流行,就没写,不过在我的博客文章中简单的写了下web端登录docker容器的方法,然后介绍文章描述了如何开启远程调用 无耻的推一波我的博客: ://www.poorops.com/#/自动拉取阿云主机实现方法参考 安装 一,安装python3.6 建议安装虚拟环境,具体步骤参考 二,安装模块 git c

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧