|
안녕하세요.
아무리 찾아봐도 자세한 내용이 없어 자문을 구하고자 합니다.
우선, 24bit color image를 load하여 영상을 form에 뿌리고자 합니다.
8bit gray image는 잘 되는데 24bit 영상의 경우 잘 되지 않습니다.
소스를 보시고 문제가 되는 부분 지적 부탁드립니다.
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 = 0;
m_BitmapHeader->biYPelsPerMeter = 0;
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);
|