本文主要是介绍cximage mix 注意图像合成时内部坐标,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
double h1,w1,h2,w2,h3,w3,h4,w4,bpp;
//getheight(w4,h4);
CString spath1 = _T("测试1");
CString spath2 = _T("测试2");
CString spath3 = _T("测试3");
CStringArray arraystr;
arraystr.Add(spath1);arraystr.Add(spath2);arraystr.Add(spath3);
CxImage img1,img2,img3,img4;
CxImage imgarray[3];
img1.Load("D:\\z1.jpg");
img2.Load("D:\\z2.jpg");
img3.Load("D:\\z3.jpg");
h1=img1.GetHeight();
w1=img1.GetWidth();
h2=img2.GetHeight();
w2=img2.GetWidth();
h3=img3.GetHeight();
w3=img3.GetWidth();
h4 = h1 + h2 + h3;
w4 = max(w3,max(w1,w2));
bpp=img1.GetBpp();
img4.Create(w4,h4,bpp);
/*img4.MixFrom(img1,0,h1+h2);
img4.MixFrom(img2,0,h1);
img4.MixFrom(img3,0,0);*/
// Y轴上方为负数;
img4.Mix(img1, CxImage::ImageOpType::OpScreen,0,-h3-h2);
img4.Mix(img2,CxImage::ImageOpType::OpScreen,0,-h3);
img4.Mix(img3,CxImage::ImageOpType::OpScreen,0,0);
if (img4.IsValid())
{
for(int idx=0; idx <3; ++idx)
{
CString sFormat = arraystr[idx];
CxImage::CXTEXTINFO textword;
img4.InitTextInfo( &textword );
_stprintf( textword.lfont.lfFaceName, _T("Times New Roman"));
textword.lfont.lfCharSet = GB2312_CHARSET ;
textword.lfont.lfHeight =20;
textword.lfont.lfWeight = 40 ;
textword.lfont.lfItalic = 0 ;
textword.lfont.lfUnderline = 0 ;
textword.fcolor = RGB( 0,0,0 );
textword.bcolor = RGB( 150, 205,205 );
textword.opaque = 0; //背景
textword.b_opacity = (float)(0)/(float)100.; //透明度
textword.b_round = (BYTE) 1 ; //四舍五入为背景矩形半径
//_stprintf( textword.text, _T("水印文字") );
//sFormat.Format(_T("测试%d"),idx+1);
memset(textword.text,0,sizeof(TCHAR)*255);
for(int i=0; i < sFormat.GetLength(); ++i)
{
textword.text[i] = sFormat.GetAt(i);
}
if(idx==0)
{
img4.DrawStringEx(0,w1/2.0,h1,&textword);
}
if(idx==1)
{
img4.DrawStringEx(0,w1/2.0,h1+h2,&textword);
}
if(idx==2)
{
img4.DrawStringEx(0,w1/2.0,h1+h2+h3,&textword);
}
}
}
img4.Save("D:\\z4.jpg",CXIMAGE_FORMAT_JPG);
这篇关于cximage mix 注意图像合成时内部坐标的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!