回调函数执行是总是不能生成位图,用colorcount统计是总是0。不知道问题出在哪里,希望高手给予帮助
LRESULT CALLBACK FrameCallbackProc(HWND hWnd, LPVIDEOHDR lpVHdr)
{
char str[50];
HDC hdc,drc;
hdc=CreateCompatibleDC(GetDC (NULL));
drc=CreateCompatibleDC(GetDC (NULL));
HBITMAP bit,bmp,tmp;
int cs;
BITMAPINFO info1;
bit=CreateCompatibleBitmap(hdc,info1.bmiHeader.biWidth ,abs(info1.bmiHeader.biHeight ) );
tmp=CreateCompatibleBitmap(drc,info1.bmiHeader.biWidth ,abs(info1.bmiHeader.biHeight ) );
capGetVideoFormat(hWnd, &info1, sizeof(info1));
if(info1.bmiHeader.biCompression == BI_RGB)
{
cs = SetDIBits(hdc, bit, 1, 240 ,lpVHdr->lpData, &info1, DIB_RGB_COLORS);
// HBITMAP tmp=CreateDIBitmap(drc,&info1.bmiHeader,CBM_INIT,bit,&info1,DIB_RGB_COLORS);
FILE *fp=fopen("d:\\bmp.bmp","wb");
file://fwrite(&bit,sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+lpVHdr->dwBufferLength,1,fp);
fwrite(&bit,lpVHdr->dwBufferLength,1,fp);
fclose(fp);
// LPBYTE DataPoint;
// DataPoint=(LPBYTE)malloc(lpVHdr->dwBufferLength);
// memcpy( DataPoint, lpVHdr->lpData, lpVHdr->dwBufferLength );
// HBITMAP bmp=(HBITMAP )LoadImage(NULL,"d:\\bbmp.bmp",0,0,0,16);
// HBITMAP bmp=(HBITMAP)DataPoint;
file://LONG aa=Color_S(bmp,H_x,H_y,H_w,H_h);
LONG aa=CountColor (tmp,H_x,H_y,H_w,H_h);
file://free(DataPoint);
sprintf(str,"%u",bmp);
MessageBox(0,str,"",0);}
DeleteObject(tmp);
DeleteObject(bit);
DeleteDC (hdc);
DeleteDC (drc);
return (LRESULT) TRUE ;
}