I am trying to display live images coming from a monochrome camera (Adimec N5A / CXP, with GenIcam standard).
From an example coming from a vendor (but in RGB 24), I am more or less able to display an image, but the color rendering is very strange (colors and shadows instead of shades of gray). I think I did something wrong in the bitmap title declaration:
bitmapInfo = (LPBITMAPINFO)malloc(sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD));
bitmapInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bitmapInfo->bmiHeader.biPlanes = 1;
bitmapInfo->bmiHeader.biBitCount = 8;
bitmapInfo->bmiHeader.biCompression = BI_RGB;
bitmapInfo->bmiHeader.biSizeImage = 0;
bitmapInfo->bmiHeader.biXPelsPerMeter = 0;
bitmapInfo->bmiHeader.biYPelsPerMeter = 0;
bitmapInfo->bmiHeader.biClrUsed = 256;
bitmapInfo->bmiHeader.biClrImportant = 0;
bitmapInfo->bmiHeader.biWidth = (LONG)width;
bitmapInfo->bmiHeader.biHeight = -(LONG)height;
I found in the bmiColors field of the BITMAPINFO structure that the biClrUsed parameter should be set to 256. Then I do not know if I need to write a block to describe 'bmiColors. I would like to use only one byte per pixel instead of the r, g and b components.
( "OnPaint" ) "SetDIBitsToDevice" . :
unsigned char *imagePtr = liveState.currentBuffer->getInfo<unsigned char *>(liveState.grabber, gc::BUFFER_INFO_BASE);
:
::SetDIBitsToDevice(dc, 0, 0, (DWORD)liveState.width, (DWORD)liveState.height, 0, 0, 0, (UINT)liveState.height, imagePtr, liveState.bitmapInfo, DIB_RGB_COLORS);
, DIB_RGB_COLORS . , DIB_PAL_COLORS. , ?
... , opencv, :-).
!