为什么回调函数出现错误??!!!

huahuayy 2008-02-21 11:28:21
这是一个基于VFW的实时捕捉和处理程序,我想在回调函数中实时计算梯度差分图像,为什么总有一行不能通过编译呢?以下是源程序,请各位高手指点~~谢谢谢谢!
capWnd = capCreateCaptureWindow (
(LPSTR) "My Capture Window", // window name if pop-up
WS_CHILD | WS_VISIBLE, // window style
0, 0, 160, 120, // window position and dimensions
(HWND)Panel1->Handle,0);
LRESULT PASCAL FrameCallback(HWND hWnd,LPVIDEOHDR lpVHDR)
{
swnd=GetSafeHwnd()
vfs=capGetVideoFormatSize(swnd);
capGetVideoFormat(swnd,lpBmp,vfs)
width=lpBmp->biWidth
height=lpBmp->biHeight
bits=lpBmp->biBitCount
BufferSize=vfs+width*height/8;
imageDate=GlobalLock(GlobalAlloc(GMEM_MOVEABLE,BufferSize));
CopyMemory(imageData+vfs,lpVHDR->lpDate,idth*height*bits/8);
LPBITMAPINFO lpBi=imageData
BYTE*ptr=lpBi+lpBi->biSize;
//定位到实际像素点
tmpLine=new BYTE[width*3];
//存放每一行像素点临时计算结果
for(int y=0;y<height-1;y++)
{for(int x=0;x<width-1;x++){
x0y0=x*3;
x1y1=x0y0+width*3+3;
x1y0=x0y0+3;
x0y1=x0y0+width*3;
r1=abs(ptr[x0y0]-ptr[x1y1]);
g1=abs(ptr[x0y0+1]-ptr[x1y1+1]);
b1=abs(ptr[x0y0+2]-ptr[x1y1+2]);
r2=abs(ptr[x1y0]-ptr[x0y1]);
g2=abs(ptr[x1y0+1]-ptr[x0y1+1]);
b2=abs(ptr[x1y0+2]-ptr[x0y1+2]);
tmpLine[x0y0]=(BYTE)(r1+r2);
tmpLine[x0y0+1]=(BYTE)(g1+g2);
tmpLine[x0y0+1]=(BYTE)(b1+b2);
}
memcpy(ptr,tmpLine,(width-1)*3);
//更新视频图像每一行
ptr+=width*3;//跳转到视频数据下一行
}
}
// ShowMessage("一切OK");

capSetCallbackOnFrame(capWnd,FrameCallback); //帧回调

capSetCallbackOnVideoStream(capWnd,(FARPROC)VideoStreamCallback); //流回调
capDriverConnect(capWnd,0);
capPreviewRate(capWnd, 50); // rate, in milliseconds
capPreview(capWnd, TRUE); // starts preview
//获取视频驱动相关性能
capDriverGetCaps(capWnd, &CapDrvCaps, sizeof (CAPDRIVERCAPS));

//获取捕获窗口状态
capGetStatus(capWnd, &CapStatus, sizeof (CAPSTATUS));
SetWindowPos(capWnd, NULL,
0,
0,
CapStatus.uiImageWidth,
CapStatus.uiImageHeight, SWP_NOZORDER | SWP_NOMOVE);

float FramesPerSec = 10.0; //每秒10帧
capCaptureGetSetup(capWnd, &CaptureParms, sizeof(CAPTUREPARMS));
//Form1->Label4->//CaptureParms.dwRequestMicroSecPerFrame
CaptureParms.dwRequestMicroSecPerFrame = (DWORD) (1.0e6 /FramesPerSec);
capCaptureSetSetup(capWnd, &CaptureParms, sizeof (CAPTUREPARMS));
//Form1->Label4->Caption=IntToStr(CaptureParms.dwRequestMicroSecPerFrame);
//Panel1->Height=240;
//Panel1->Width=320;
}
[color=#FF0000][C++ Error] Unit1.cpp(37): E2108 Improper use of typedef 'LRESULT'
[C++ Error] Unit1.cpp(37): E2108 Improper use of typedef 'LRESULT'[/color]
...全文
135 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
gyj_china 2008-03-14
函数里面放函数的实现当然不行啊!把LRESULT PASCAL FrameCallback(HWND hWnd,LPVIDEOHDR lpVHDR)的实现放到外面,然后在函数内部FrameCallback(HWND hWnd,LPVIDEOHDR lpVHDR)调用就行了.
回复
laowang2 2008-02-23
顶。
回复
ydlchina 2008-02-22
LRESULT PASCAL FrameCallback(HWND hWnd,LPVIDEOHDR lpVHDR)
该函数的定义放在全局位置,不要放在某个事件里定义,要单独定义
回复
相关推荐
发帖
茶馆
创建于2007-08-02

529

社区成员

C++ Builder 茶馆
申请成为版主
帖子事件
创建了帖子
2008-02-21 11:28
社区公告
暂无公告