注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

_

_

 
 
 

日志

 
 

XIMAGE 图象剪切  

2012-09-10 20:45:36|  分类: 默认分类 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

{
??? CString strPath;

??? CMapStringToString map;
??? map.SetAt(_T(".jpg"), _T(".jpg"));
??? map.SetAt(_T(".jpeg"), _T(".jpeg"));
??? map.SetAt(_T(".JPG"), _T(".JPG"));
??? map.SetAt(_T(".JPEG"), _T(".JPEG"));

??? CStringList fileList;
??? strPath.Format(_T("H:\\work\\prj_work\\work\\20120811_20121111_E_YIFAN_PHP_WEB\\02_Src\\zoom\\"));
??? CCommonFunc::S_FindDirFile(strPath, fileList, TRUE, map);
??? POSITION pos = fileList.GetHeadPosition();
??? while(pos) {

??????? CString strF = fileList.GetNext(pos);

??????? CxImage *pImageAll = new CxImage(strF.GetBuffer(0), CXIMAGE_FORMAT_JPG);
??????? BOOL b = pImageAll->Load(strF.GetBuffer(0), CXIMAGE_FORMAT_BMP); // -> BMP然后好用
??????? CxImage image;

??????? if(b) {
??????????? int iM = 800;???
??????????? int iH = pImageAll->GetHeight();
??????????? int iW = pImageAll->GetWidth();
??????????? double iSp = (double)iW / (double)iH;
??????????? if(iW <= iM) {
??????????????? iW = iM;
??????????????? iH = iW / iSp;
??????????????? pImageAll->Resample(iW, iH, 1, ((CxImage *)pImageAll));
??????????? }
??????????? //pImageAll->Save(strF.GetBuffer(0), CXIMAGE_FORMAT_JPG);

??????????? if(iW > iM) {
??????????????? iW = iM;
??????????????? iH = iW / iSp;
??????????????? if(iH < iM) {
??????????????????? iH = iM;
??????????????????? iW = iH * iSp;
??????????????? }
??????????????? //pImageAll->Resample(iW, iH, 1, ((CxImage *)pImageAll));
??????????? }
??????????? if(iH > iM || iW > iM) {
???????????????? // pImageAll->Crop(0, 0, iM, 530);
??????????? }
??????????? pImageAll->Crop(0, 0, iM, 520, &image);

??????????? CxImage *imgDst = new CxImage;???????????????????????? //剪切目标图像
??????????? CRect rect(0, 0, 800, 520);
??????????? pImageAll->Crop(rect, imgDst);??????????????????????????? //crop
??????????? imgDst->Save(strF.GetBuffer(0), CXIMAGE_FORMAT_JPG);//另存为
??????? } else {
??????? }
??????? //b = pImageAll->Save(strF.GetBuffer(0), CXIMAGE_FORMAT_JPG);
??????? //b = image.Save(strF.GetBuffer(0), CXIMAGE_FORMAT_JPG);
??????? //if(b == FALSE) {
??????? //??? AfxMessageBox(_T("err"));
??????? //}

??????? if(pImageAll) {
??????????? delete pImageAll;
??????? }

??????? this->SetWindowText(strF);
??? }
}

  评论这张
 
阅读(392)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017