2013年3月22日星期五

CxImage给图片加水印文字

 

2011-04-25 22:09:42|  分类: VC++ |字号 订阅

void CTest2Dlg::OnBtnAddWord()
{
 // TODO: Add your control notification handler code here
 CxImage imagesy; 
 if( !imagesy.Load("C:\\z2.jpg", CXIMAGE_FORMAT_JPG))
 { 
 return ;
 }
 if (imagesy.IsValid())
 {
  CxImage::CXTEXTINFO textword;
  imagesy.InitTextInfo( &textword );
  _stprintf( textword.lfont.lfFaceName, _T("Times New Roman"));
  textword.lfont.lfCharSet = GB2312_CHARSET ;
  textword.lfont.lfWeight = 8 ;
  textword.lfont.lfItalic = 0 ; 
  textword.lfont.lfUnderline = 0 ; 
  textword.fcolor = RGB( 255,255,160 );
  textword.bcolor = RGB( 0, 80,160 );
  textword.opaque = 1; //背景
  textword.b_opacity = (float)(0)/(float)100.; //透明度
  textword.b_round = (BYTE) 10 ; //四舍五入为背景矩形半径
 // textword.smooth = (BYTE)1; //平滑选项的文本
  _stprintf(textword.text, _T("水印文字") );

  imagesy.DrawStringEx(0,0,100,&textword);
  imagesy.Save("C:\\z2_sy.jpg",CXIMAGE_FORMAT_JPG);
 }
 return;
}

没有评论:

发表评论