|
引用 9 楼 iwillbeback008 的回复:
你指的read是用摄像头驱动中提供的XX_OControl()函数提供的功能么?
谢谢了!
这个得看看驱动中是如何实现的,iocontrol也可以,read也可以的,下面是主要代码你看下,读取的是p-path的rgb数据,如果读c-path的yuv的话还需要转换数据格式
f=ReadFile(hCam,bufOut,pic_size,(LPDWORD)&nBytesRead,NULL);
BITMAPINFO RGB16BitsBITMAPINFO;
ZeroMemory(&RGB16BitsBITMAPINFO, sizeof(BITMAPINFO));
RGB16BitsBITMAPINFO.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
RGB16BitsBITMAPINFO.bmiHeader.biWidth = 320;
RGB16BitsBITMAPINFO.bmiHeader.biHeight = 240;
RGB16BitsBITMAPINFO.bmiHeader.biPlanes = 1;
RGB16BitsBITMAPINFO.bmiHeader.biBitCount = 16;
RGB16BitsBITMAPINFO.bmiHeader.biCompression = BI_BITFIELDS;
//在填充数据
BITMAPFILEHEADER bmBITMAPFILEHEADER;
ZeroMemory(&bmBITMAPFILEHEADER, sizeof(BITMAPFILEHEADER));
bmBITMAPFILEHEADER.bfType = 0x4d42; //bmp
bmBITMAPFILEHEADER.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) +16/*调色板结构大小*/;
bmBITMAPFILEHEADER.bfSize = bmBITMAPFILEHEADER.bfOffBits + (pic_size);
//保存图像数据
//write bitmap file header
fwrite(&bmBITMAPFILEHEADER, sizeof(BITMAPFILEHEADER), 1, mStream);
//write bitmap info
fwrite(&(RGB16BitsBITMAPINFO.bmiHeader), sizeof(BITMAPINFOHEADER), 1, mStream);
//write palette info
fwrite(&RGB565, 16, 1, mStream);
//write bitmap pixels data
fwrite(bufOut, pic_size, 1, mStream);
//close file
fclose(mStream); |
|