| 发表于:2007-09-06 10:14:565楼 得分:100 |
void ctestview::onloadimg() { invalidate(); updatewindow(); cdc *dc = getdc(); cdc thdc; hbitmap thbm; bitmap bmp; cfiledialog dlg(true, null,null, ofn_hidereadonly ¦ ofn_overwriteprompt, null, null); if(dlg.domodal() == idok) { oldfile = dlg.getpathname(); thbm=(hbitmap)loadimage(null,oldfile,image_bitmap,0,0, lr_loadfromfile ¦lr_createdibsection);//载入位图 getobject(thbm,sizeof(bmp),&bmp); if(thdc == null) { thdc.createcompatibledc(dc); } else { afxmessagebox( "图像处理出错,请关闭程序重新打开! "); } getobject(thbm,sizeof(bmp),&bmp);//取得位图信息 selectobject(thdc,thbm);//选入位图至内存dc dc-> bitblt(0,0,bmp.bmwidth, bmp.bmheight,&thdc,0,0,srccopy); deleteobject(thbm);//删除位图 } releasedc(dc); deletedc(thdc); } 可以重复打开. | | |
|