| 发表于:2007-08-09 12:32:22 楼主 |
我想在图片上贴文字,现在基本贴好了,但是字太大了,所以设置字体大小,但是好象没有什么反映,大家看看,问题出在哪里。 hdc pdc=::getdc(m_hwnd); hbitmap hbmp = (hbitmap)::loadimage(null,lpstrimagepath, image_bitmap, 0, 0, lr_loadfromfile ¦lr_createdibsection); //加载图片 if( hbmp == null ) { return ; } bitmap bm; cbitmap* pbitmap=new cbitmap; pbitmap-> attach(hbmp); //加载图片 pbitmap-> getobject(sizeof(bm),&bm); hdc hdc,hdcmem;//,hdcmem2; hdc=pdc; hbitmap hbitmap=::createcompatiblebitmap(hdc,bm.bmwidth,bm.bmheight);//建立空白位图 hdcmem=::createcompatibledc(hdc); ::setbkmode(hdcmem,transparent); //设置透明背景 hbitmap hbitmapold=(hbitmap)::selectobject(hdcmem,hbmp);//将位图写入 ::setmapmode(hdcmem,mm_text); ///////////////////////////// cfont * pfont; pfont = new cfont; pfont-> createfont(10, // nheight 0, // nwidth 0, // nescapement 0, // norientation fw_bold, // nweight true, // bitalic false, // bunderline 0, // cstrikeout ansi_charset, // ncharset out_default_precis, // noutprecision clip_default_precis, // nclipprecision default_quality, // nquality default_pitch ¦ ff_swiss, // npitchandfamily _t( "arial ")); // lpszfac ::selectobject(hdcmem,pfont); ::settextcolor(hdcmem,rgb(255,0,0)); //设置文字颜色 cstring strstudname= " "; //接收字符的串 cstring strname= " "; for(int j = 0; j < nid; j++) { strname.format( "%s%c ", "name ",49+j); getprivateprofilestring( "studentinfo ",strname, "默认姓名 ", strstudname.getbuffer(max_path),max_path, ".\\advconfig.ini "); cstring str; str.format( "%s ",strstudname); ::textout(hdcmem,2+sizeimage.cx*j,10,str,str.getlength()); } hbitmap hbmpnew=(hbitmap)::selectobject(hdcmem,hbitmapold);//创建位图 ::deletedc(hdcmem); ::deleteobject(hbitmap); pbitmap-> detach(); //卸载以前的位图资源 pbitmap-> attach(hbmpnew); //加载新的位图 addbitmap(pbitmap,crmask); //将位图加入到图象列表 delete pbitmap; |
|
|
|
|