void CFacedetectionDlg::LoadOriPixel(CDib *pDib)
{
BYTE *colorTable;
colorTable = (BYTE *)pDib->m_pDibBits;//获取位图数据区的首指针
int byteBitCount  = pDib->GetBiBitCount()/8;////每个像素所占的字节数 m_tOriPixelArray  = new RGBQUAD*[m_nWndHeight];
m_tResPixelArray  = new RGBQUAD*[m_nWndHeight];
for(int l=0 ; l<m_nWndHeight; l++)
{
m_tOriPixelArray[l] = new RGBQUAD[m_nWndWidth];
m_tResPixelArray[l] = new RGBQUAD[m_nWndWidth];
} int count = 0;
for(int i=m_nWndHeight-1; i>=0; i--)
{
for(int j=0; j<m_nWndWidth; j++)
{
m_tOriPixelArray[i][j].rgbBlue =colorTable[count++];//////?????????????????????????????????
m_tOriPixelArray[i][j].rgbGreen=colorTable[count++];//////??????????????????
m_tOriPixelArray[i][j].rgbRed  =colorTable[count++];//////????????????????????????????????????????
m_tOriPixelArray[i][j].rgbReserved = 0;
m_tResPixelArray[i][j]=m_tOriPixelArray[i][j];
// count=count-2;
count += byteBitCount-3;
}
count += (4-(m_nWndWidth*byteBitCount)%4)%4;
} method1 = new CLikelyHood(m_tOriPixelArray,m_nWndWidth,m_nWndHeight);}上面这段代码的作用是读入原图数据,可是,BMP的格式是:文件头,文件信息头,调色板,数据。
这个函数中m_tOriPixelArray[i][j].rgbBlue =colorTable[count++];//////?????????????????????????????????
m_tOriPixelArray[i][j].rgbGreen=colorTable[count++];//////??????????????????
m_tOriPixelArray[i][j].rgbRed  =colorTable[count++];//////????????????????????????????????????????
这是什么意思?colorTable[count++]得到的应该是该像素点在调色板中的索引呀??应该不是颜色分量呀????

解决方案 »

  1.   

    http://topic.csdn.net/u/20090530/21/5e1619ea-6014-4c75-80ce-7f1e19af8852.html
      

  2.   

    但是,如果BMP图像若不是真色彩呢?那这个程序就不对了吗?
      

  3.   

    多于8位的 无需调色板
    colorTable = (BYTE *)pDib->m_pDibBits;//获取位图数据区的首指针  
    本来获得的就是图像数据 请问哪来的调色板呢?
      

  4.   

    colorTable[count++]得到是颜色分量
    typedef struct tagRGBQUAD {
      BYTE rgbBlue;// 蓝色的亮度(值范围为0-255)
      BYTE rgbGreen; // 绿色的亮度(值范围为0-255)
      BYTE rgbRed; // 红色的亮度(值范围为0-255)
      BYTE rgbReserved;// 保留,必须为0
      } RGBQUAD;
      

  5.   

    colorTable = (BYTE *)pDib->m_pDibBits;//获取位图数据区的首指针
    这里获取的是数据段的指针
    m_tOriPixelArray[i][j].rgbBlue =colorTable[count++];//////????????????????????????????????? 
    m_tOriPixelArray[i][j].rgbGreen=colorTable[count++];//////?????????????????? 
    m_tOriPixelArray[i][j].rgbRed  =colorTable[count++];//////
    这里count依次递增,遍历数据段,都是颜色信息
    至于有没有调色板,你调试一下,看看
    byteBitCount  = pDib->GetBiBitCount()/8;////每个像素所占的字节数 
    这里pDib->GetBiBitCount()就是图片位数