晕啊...bmp的象素值始终不对
cchh 2006-01-25 03:28:01 可怜在fireworks中看到的对应位置的象素值始终和我取出来的值不一致.....请大家帮忙啊
pBitmap的值是对的,也是可以写出来的
CBitmap pBitmap ;
OLE_HANDLE m_picHandle;
pPic->get_Handle(&m_picHandle) ;
pBitmap.Attach((HGDIOBJ) m_picHandle);
GetObject(pBitmap.m_hObject, sizeof(bm), &bm);
CFile cf("d:\\11.txt",CFile::modeReadWrite) ;
int nIndex = 0;
int i = 432 ;
int j = 228 ;
int w1 = (bm.bmWidth*3+3)/4*4;
////24位的象素色彩.......前后左右3个点内,值都对不上
CString cs ;
for (i = 430 ;i<435 ;i++)
{
nIndex = (j-1)*w1 + i*3 ;
unsigned char *p = (unsigned char*) bm.bmBits ;
p += nIndex;
unsigned char c1 = p[0];
p ++ ;
unsigned char c2 = p[0] ;
p ++ ;
unsigned char c3 = p[0] ;
cs.Format("RGB(%x,%x,%x)",c1,c2,c3) ;
cf.Write(cs.GetBuffer(cs.GetLength()),cs.GetLength()) ;
}
cf.Close();