//一下难以说清楚,下面是知道数据,用16色画图的办法。
void CDrawbmpView::OnDraw(CDC* pDC)
{
CDrawbmpDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
int hei=480;
int wid=640;
int count,ofs;
BYTE *ScreenPtr0=0;
BYTE *ScreenPtr=0;
COLORREF color_table[16]={// 0x00bbggrr
0x000000, //0
0x000080, //1
0x008000, //2
0x008080, //3
0x800000, //4
0x800080, //5
0x808000, //6
0x808080, //7
0xC0C0C0, //8
0x0000FF, //9
0x00FF00, //10
0x00FFFF, //11
0xFF0000, //12
0xFF00FF, //13
0xFFFF00, //14
0xFFFFFF };//15
// open
CFile if_hnd;
if(!if_hnd.Open("tmp.bmp",CFile::modeRead|CFile::shareExclusive))
{
AfxMessageBox("Cann't open image file!");
return;
}
// get mem
unsigned fsize;
fsize =if_hnd.GetLength();//
ScreenPtr0=(BYTE *)new char[fsize]; //
// read all in
if_hnd.Read(ScreenPtr0,fsize);//
// image data are in buffer
if(if_hnd) if_hnd.Close();
int count1=0;
//
for (count1=0; count14) & 0x0F;
SetPixel(pDC->m_hDC,2*count,count1,color_table[ofs]);
//
ofs=ScreenPtr[count] & 0x0F;
SetPixel(pDC->m_hDC,2*count+1,count1,color_table[ofs]);
}
}
if(ScreenPtr0) delete []ScreenPtr0;
}