VC中使用Gdi+合并jpg图片(2)
二。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;
}
例子:
CombinePic(L"image/bmp","12.bmp","1.bmp","2.bmp");
有了上面的功能,其他的就没问题了。
- 上一篇:VC-摄像头控制SDK源码
- 下一篇:VC通过HTTP方式获取网页