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值了
为什么我画出来就不是了
请问大哥
错那里了
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值了
为什么我画出来就不是了
请问大哥
错那里了
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函数得到不同的值.
然后才是你要的吧。
k= *lpDst + i*bm[0].bmWidthBytes+j*pixelByte;
m_BData=new BYTE [bm[0].bmHeight*bm[0].bmWidth];
上面这个不对,内存的大小并不是高*宽,每一个点并不是占一个字节,而且每一行还有对齐问题,所以写作:
应该用GetBitmap先得到相应位图的BITMAP对象,用里面的bmHeight*bmWidthBytes作内存大小。