m_BData=new BYTE [bm[0].bmHeight*bm[0].bmWidth];
CBitmap *bmp=CBitmap::FromHandle(hBitmap[0]);
bmp->GetBitmapBits(bm[0].bmHeight*bm[0].bmWidth,(void*)m_BData);for (int i=0;i<bm[0].bmHeight;i++)
{
for (int j=0;j<bm[0].bmWidth;j++)
{
k=i*bm[0].bmWidthBytes+j*pixelByte;
                  m_BData[k] m_BData[k+1] m_BData[k+2]
}
各拉大哥这m_BData[k] m_BData[k+1] m_BData[k+2]
是不是就是对应的RGB值了
为什么我画出来就不是了
请问大哥
错那里了

解决方案 »

  1.   

    lpBits
    Points to the buffer that is to receive the bitmap. The bitmap is an array of bytes. The bitmap byte array conforms to a structure where horizontal scan lines are multiples of 16 bits
    你得到点的RGB值用Getpixel函数,然后用GetRValue, GetBValue, GetGValue函数得到不同的值.
      

  2.   

    楼主你没有注意位图的图像数据指针的地址,先找到 lpDst ;
    然后才是你要的吧。
       k= *lpDst + i*bm[0].bmWidthBytes+j*pixelByte;
      

  3.   

    代码好像没有问题,用GetBitmapBits获取的是是RGB值,你是怎么画图的呢?
      

  4.   

    仔细看了一下,又发现有点问题了,
    m_BData=new BYTE [bm[0].bmHeight*bm[0].bmWidth]; 
    上面这个不对,内存的大小并不是高*宽,每一个点并不是占一个字节,而且每一行还有对齐问题,所以写作:
    应该用GetBitmap先得到相应位图的BITMAP对象,用里面的bmHeight*bmWidthBytes作内存大小。
      

  5.   

    顶楼上,分配内存大小应该是bmHeight*bmWidthBytes。