CBitmap::GetBitmapBits和IMediaDet::GetBitmapBits有什么区别?
用IMediaDet::GetBitmapBits获得的位图数据能像CBitmap类一样处理吗?

解决方案 »

  1.   

    获取的数据有所不同。CBitmap::GetBitmapBits获取的是位图象素数组数据而缺少位图的头信息,位图的头信息里包括了该位图的色深,宽度,高度和调色版的信息。而IMediaDet::GetBitmapBits获取的数据中则是包括了位图头信息的,并在该信息之后附上了位图象素信息。
      

  2.   

    这是其中的部分代码:  
    CComPtr<IMediaDet>  pDet;  
    char  *pBuffer;  
    pDet->GetBitmapBits(0,  0,  pBuffer,  width,  height); 
    那如何在窗口显示存在pBuffer的位图?
    我用以下代码有问题啊?
    char *pData = pBuffer + sizeof(BITMAPINFOHEADER);            
    int i,j;
    for (i=0; i<m_orgHeight; i++)
    for(j=0; j<m_orgWidth; j++)
    {
        pDC->SetPixel(j,i,RGB(
            pData[width*(height-i)+j],
            pData[width*(height-i)+j],
            pData[width*(height-i)+j]));
    }
    请帮忙看看?谢谢了!
      

  3.   

    没有判断调色板的大小,读取头信息中biBitCount获得色深,并用计算式
    #define PAL_ITEM_COUNT(b)   ( ((b)==8)?256:( ((b)==4)?16:( (b)==1)?2:0) )
    来计算调色板的个数int nItem=PAL_ITEM_COUNT(biBitCount);
    当色深为8位的时候用一个字节保存一个象素点,同理16位=2byte,24=3byte,32=4byte;
    这样应该明白怎么显示象素点了吧。但是当色深小于等于8的时候会使用调色板的颜色,所以这样设置点的颜色是不对的。可以使用API函数来打印图像。StretchDIBits其定义为:
    int StretchDIBits(
      HDC hdc,                      // handle to DC
      int XDest,                    // x-coord of destination upper-left corner
      int YDest,                    // y-coord of destination upper-left corner
      int nDestWidth,               // width of destination rectangle
      int nDestHeight,              // height of destination rectangle
      int XSrc,                     // x-coord of source upper-left corner
      int YSrc,                     // y-coord of source upper-left corner
      int nSrcWidth,                // width of source rectangle
      int nSrcHeight,               // height of source rectangle
      CONST VOID *lpBits,           // bitmap bits
      CONST BITMAPINFO *lpBitsInfo, // bitmap data
      UINT iUsage,                  // usage options
      DWORD dwRop                   // raster operation code
    );