求助:图像拼接 我要写图像拼接方面的论文,就是把两幅图拼接成一幅,不知道怎么用VC来实现,哪位有这方面的资料,可以传点给我吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 bmp图片合并BOOL CombinePic(const WCHAR *format, const CString &strDst, const CString &strPic1, \ const CString &strPic2){BOOL bCombine = false;int nRet = 0;CLSID clsid;nRet = GetEncoderClsid(format,&clsid);if (nRet>=0){ USES_CONVERSION; Bitmap bmp1(A2W(strPic1)); Bitmap bmp2(A2W(strPic2)); int nWidth = 0, nHeight = 0; nWidth = bmp1.GetWidth(); //假设两图片大小同 nHeight = bmp1.GetHeight(); Bitmap bmpCombine(2*nWidth,nHeight); //高不变,宽*2,水平合并 Graphics * pG = NULL; pG = Graphics::FromImage(&bmpCombine); if (pG!=NULL) { pG->DrawImage(&bmp1,0,0); pG->DrawImage(&bmp2,nWidth,0); bmpCombine.Save(A2W(strDst),&clsid,NULL); }}return bCombine;}int GetEncoderClsid(const WCHAR *format, CLSID *pClsid){int nRet = -1;ImageCodecInfo * pCodecInfo = NULL;UINT nNum = 0,nSize = 0;GetImageEncodersSize(&nNum,&nSize);if (nSize<0){ return nRet;}pCodecInfo = new ImageCodecInfo[nSize];if (pCodecInfo==NULL){ return nRet;}GetImageEncoders(nNum,nSize,pCodecInfo);for (UINT i=0; i<nNum; i++){ if (wcscmp(pCodecInfo[i].MimeType,format)==0) { *pClsid = pCodecInfo[i].Clsid; nRet = i; delete[] pCodecInfo; return nRet; } else { continue; }}delete[] pCodecInfo;return nRet;}例子:CombinePic(L"image/bmp","12.bmp","1.bmp","2.bmp");这是GDI+做的,有GDI+的初始化和销毁工作要做,网上有这方面的资料。 怎么读图片?,这个函数自动完成读图的,你只要给出两个图片的位置就可以了,strPic1和strPic2分别表示两张图片的路径,这个是bmp图片的拼接,如果图片是其他格式的转换成BMP格式就可以了。 USES_CONVERSION是什么意思啊?程序报错! 因为这个程序用到了GDI+, 如果你使用的是VC6.0的话,就必须加载GDI+的函数库。下面的网址上面有完整的怎么在VC6.0中使用GDI+的方法对你有帮助http://www.cnblogs.com/XieKe-cs01/archive/2006/03/14/349816.aspx 我也在做这个,可以把你的代码给我一份吗?谢谢邮箱:[email protected] 你好!能不能把你的代码给我一份吗? 我的毕业设计也是做这个。谢谢!邮箱:[email protected] 太感谢了,急寻代码的啊。谢谢[email protected] 你好,我也想要这个代码啊,先谢谢了啊,邮箱:[email protected] 我也需要这个代码,谢谢了哈邮箱:[email protected] 控制台不能输入中文是怎么回事? 求助 如何将外加类文件中的类显示再Class Wizard窗口里? 如何得到一个CBitmap对象? 如何使用CPen类选择各种画笔? 数组组件的实现方法? 送分啊!!救命啊!! Udp重发机制的问题 一个问题,再线等候,高分想送!!! 有没有办法知道SOCKET的类型? 如何替换整个菜单条?就像切换文档时程序替换所有菜单条与工具栏一样 请教透明效果的问题 老问题:自编的CHtmlView浏览器,怎么截获超连接,不让新窗口在IE中打开?
BOOL CombinePic(const WCHAR *format, const CString &strDst, const CString &strPic1, \
const CString &strPic2)
{
BOOL bCombine = false;
int nRet = 0;
CLSID clsid;
nRet = GetEncoderClsid(format,&clsid);
if (nRet>=0)
{
USES_CONVERSION;
Bitmap bmp1(A2W(strPic1));
Bitmap bmp2(A2W(strPic2));
int nWidth = 0, nHeight = 0;
nWidth = bmp1.GetWidth(); //假设两图片大小同
nHeight = bmp1.GetHeight();
Bitmap bmpCombine(2*nWidth,nHeight); //高不变,宽*2,水平合并
Graphics * pG = NULL;
pG = Graphics::FromImage(&bmpCombine);
if (pG!=NULL)
{
pG->DrawImage(&bmp1,0,0);
pG->DrawImage(&bmp2,nWidth,0);
bmpCombine.Save(A2W(strDst),&clsid,NULL);
}
}
return bCombine;
}
int GetEncoderClsid(const WCHAR *format, CLSID *pClsid)
{
int nRet = -1;
ImageCodecInfo * pCodecInfo = NULL;
UINT nNum = 0,nSize = 0;
GetImageEncodersSize(&nNum,&nSize);
if (nSize<0)
{
return nRet;
}
pCodecInfo = new ImageCodecInfo[nSize];
if (pCodecInfo==NULL)
{
return nRet;
}
GetImageEncoders(nNum,nSize,pCodecInfo);
for (UINT i=0; i<nNum; i++)
{
if (wcscmp(pCodecInfo[i].MimeType,format)==0)
{
*pClsid = pCodecInfo[i].Clsid;
nRet = i; delete[] pCodecInfo;
return nRet;
}
else
{
continue;
}
}
delete[] pCodecInfo;
return nRet;
}例子:
CombinePic(L"image/bmp","12.bmp","1.bmp","2.bmp");
这是GDI+做的,有GDI+的初始化和销毁工作要做,网上有这方面的资料。
http://www.cnblogs.com/XieKe-cs01/archive/2006/03/14/349816.aspx
谢谢
邮箱:[email protected]
谢谢!
邮箱:[email protected]
[email protected]
邮箱:[email protected]
邮箱:[email protected]