int rc = 0;
HANDLE hCam = CreateFile (TEXT("CIS1:"), GENERIC_WRITE | GENERIC_READ,
0, NULL, OPEN_EXISTING, 0, NULL); //打开设备句柄
if (hCam == INVALID_HANDLE_VALUE)
{
rc = GetLastError();
printf ("can't open file rc = %d\r\n", rc);
AfxMessageBox(_T("无法打开设备!请检查设备是否已被占用。"));
}
WORD width=GetSystemMetrics(SM_CXSCREEN);
WORD height=GetSystemMetrics(SM_CYSCREEN);//屏幕尺寸
BYTE* DDBdata=new BYTE[width*height*2];//分配用于存数据的空间
BOOL ret;
PINGPONG_PR image; //定义结构体用于存RGB图像地址;
ret = DeviceIoControl(hCam,IOCTL_CAM_GETINFO,NULL,NULL,(PBYTE)&image,NULL,NULL,NULL); //启动预览功能
if(!ret)
AfxMessageBox(_T("启动预览失败!"));
//SetKMode(TRUE);
memcpy(DDBdata,(void *)image.rgb_address,width*height*2);
//SetKMode(FALSE);
CDC* pDC ;
pDC= new CClientDC(this);//简单的为图画刷
CBitmap bitmap1;
//bitmap1.LoadOEMBitmap(IDB_DAN);
bitmap1.CreateBitmap(240,320,1,16,DDBdata);
CBrush brush1;
brush1.CreatePatternBrush(&bitmap1);
pDC->SelectObject(&brush1);
pDC->Rectangle (0,0,240,320);
delete []DDBdata;
关键是memcpy(DDBdata,(void *)image.rgb_address,width*height*2);不能顺利的取到数据!!!
SetKMode(TRUE); 这个在wince6.0中不能使用。
那应该怎样处理这个问题呢?
谢谢
qq:274571716