| 发表于:2007-12-19 11:37:4810楼 得分:0 |
前几天我也刚刚学了这个,拿出大家看一下,比较有没有更简单的方法 代码如下: (1)在头文件里的加: #define videoheight 600 #define videowidth 800 bitmapinfo bitinfo; bitmapfileheader bitfile; byte imgbuf[videowidth*videoheight*3]; byte imgbuf_temp[videowidth*videoheight*3]; #define bheight bitinfo.bmiheader.biheight #define bwidth bitinfo.bmiheader.biwidth (2)初始化 bitinfo.bmiheader.bibitcount = 24; bitinfo.bmiheader.biclrimportant = 0; bitinfo.bmiheader.biclrused = 0; bitinfo.bmiheader.bicompression = bi_rgb; bitinfo.bmiheader.biheight = videoheight; bitinfo.bmiheader.biwidth = videowidth; bitinfo.bmiheader.biplanes = 1; bitinfo.bmiheader.bisize = 40; bitinfo.bmiheader.bisizeimage = videowidth*videoheight*3; bitinfo.bmiheader.bixpelspermeter = videowidth; bitinfo.bmiheader.biypelspermeter = videoheight; (3)在你的消息响应里的代码 cfiledialog dlg(true,null,null,ofn_hidereadonly, "bmp(*.bmp) ¦*.bmp ¦ ¦",null); if(dlg.domodal() == idok) pathname = dlg.getpathname(); cfile f; f.open(pathname , cfile::moderead , null); f.read(&bitfile,sizeof(bitmapfileheader)); f.read(&bitinfo,sizeof(bitmapinfoheader)); f.read(imgbuf,bwidth*bheight*3); memcpy(imgbuf_temp,imgbuf,bwidth*bheight*3); cdc memdc; cbitmap bitmap; cclientdc dc(this); bitmap.createcompatiblebitmap(&dc,bwidth,bheight); memdc.createcompatibledc(&dc); memdc.selectobject(&bitmap); setstretchbltmode(memdc.m_hdc,blackonwhite);//coloroncolor); stretchdibits(memdc.m_hdc,0,0,bwidth,bheight, 0,0,bwidth,bheight,imgbuf,&bitinfo,dib_rgb_colors,srccopy); dc.bitblt(0,0,bwidth,bheight,&memdc,0,0,srccopy); memdc.deletedc(); | | |
|