|
우선, Camera에 의해 Color 영상 buffer 는 채워지게 됩니다.
그 buffer에 의해 DIB를 생성하고 화면에 출력하려고 합니다.
아래 DIB 생성에 따른 코드인데 왜 영상이 Gray-Scale로만 화면에 출력되는지 가르침 부탁드립니다.
int nBitCount = 24;
int numColors = 256;
DWORD dwSizeImage = m_nHeight * (DWORD)((m_nWidth*nBitCount/8+3) & ~3 );
int nSizeBitmapHeader;
if( nBitCount == 8 ) {
nSizeBitmapHeader = sizeof(BITMAPINFOHEADER) + dwSizeImage + sizeof(RGBQUAD)*(1<<nBitCount);
else if( nBitCount == 24 ) {
nSizeBitmapHeader = sizeof(BITMAPINFOHEADER) + dwSizeImage;
m_BitmapHeader = (BITMAPINFOHEADER*) new char [nSizeBitmapHeader];
m_BitmapHeader->biSize = sizeof(BITMAPINFOHEADER);
m_BitmapHeader->biWidth = m_nWidth;
m_BitmapHeader->biHeight = -m_nHeight;
m_BitmapHeader->biPlanes = 1;
m_BitmapHeader->biBitCount = nBitCount;
m_BitmapHeader->biCompression = BI_RGB;
m_BitmapHeader->biSizeImage = dwSizeImage;
m_BitmapHeader->biXPelsPerMeter = 0x0ec4;
m_BitmapHeader->biYPelsPerMeter = 0x0ec4;
m_BitmapHeader->biClrUsed = 0;
m_BitmapHeader->biClrImportant = 0;
if( nBitCount == 8 ) {
RGBQUAD* pRGB = (RGBQUAD*)(m_BitmapHeader+1);
for( int i = 0; i < numColors; i++ ) {
pRGB->rgbRed = pRGB->rgbGreen = pRGB->rgbBlue = i;
pRGB->rgbReserved = 0;
pRGB++;
}
}
SetStretchBltMode( m_hDC, COLORONCOLOR );
SetDIBitsToDevice( m_hDC, 0, 0, m_nWidth, m_nHeight, 0, 0, 0, m_nHeight, (BYTE*)m_BmpData[m_nIndex], (LPBITMAPINFO)m_BitmapHeader, DIB_RGB_COLORS);
|