123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807 |
- // ImportPhoto.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "ImportPhoto.h"
- #include "MyLock.h"
- #include "ZipTypeDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // ImportPhoto dialog 拷贝失败
- ImportPhoto::ImportPhoto(CWnd* pParent /*=NULL*/)
- : CDialog(ImportPhoto::IDD, pParent)
- {
- //{{AFX_DATA_INIT(ImportPhoto)
- // NOTE: the ClassWizard will add member initialization here
- m_mode=0;
- //}}AFX_DATA_INIT
- m_pArray2=NULL;
- m_pDesArray=NULL;
- m_exitcode=0;
- m_bOverWrite=1;
- m_bBeautifySkinFrom=0;
- m_bOrigin=0;
- m_bSaveUploadTask=0;
- m_bCopyToLocal=0;
- m_nOutputSize=0;
- m_bOfmat=0;
- m_nphototype=-1;
- m_bAddname=0;
- beginno=-1;
- m_bautono=1;
- }
- void ImportPhoto::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(ImportPhoto)
- DDX_Control(pDX, IDC_PROGRESS1, m_progress);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(ImportPhoto, CDialog)
- //{{AFX_MSG_MAP(ImportPhoto)
- ON_WM_CLOSE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // ImportPhoto message handlers
- void ImportPhoto::OnOK()
- {
- // TODO: Add extra validation here
- }
- void ImportPhoto::OnCancel()
- {
- // TODO: Add extra cleanup here
- }
- int ImportPhoto::GetFileNo(CString dir)
- {
- if(m_bautono==0)
- {
- int a=beginno;
- beginno++;
- return a;
- }
- CString path;
- CString path2;
- CString path3;
- CString path4;
- int begin=1;
- CString temp;
- CStringArray array;
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(dir), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_dir();
- for (it = coo.begin();coo.end() != it;it ++)
- {
- temp=(*it).c_str();
- if(::FindArray (&array, temp)==-1)
- array.Add (temp);
- }
- BOOL bFind=1;
- while(bFind)
- {
- bFind=0;
- for(int i=0; i<array.GetSize (); i++)
- {
- dir=array.ElementAt (i);
- path.Format ("%s%03d.jpg", dir, begin);
- path2.Format ("%s%03d.raw", dir, begin);
- path3.Format ("%s%03d.cr2", dir, begin);
- path4.Format ("%s%03d.NEF", dir, begin);
- while(::CheckFileExist (path) || ::CheckFileExist (path2) || ::CheckFileExist (path3) || ::CheckFileExist (path4))
- {
- begin++;
- path.Format ("%s%03d.jpg", dir, begin);
- path2.Format ("%s%03d.raw", dir, begin);
- path3.Format ("%s%03d.cr2", dir, begin);
- path4.Format ("%s%03d.NEF", dir, begin);
- bFind=1;
- }
- }
- }
- beginno=begin+1;
- return begin;
- }
- void FilterFileName(CString &str)
- {
- //printf("Jeff:保存目录old:%s\n\n",str);
- ///\:*?"<>|
- str.Replace("/", "");
- str.Replace("\\", "");
- str.Replace(":", "");
- str.Replace("*", "");
- str.Replace("?", "");
- str.Replace("\"", "");
- str.Replace("<", "");
- str.Replace(">", "");
- str.Replace("|", "");
- //printf("Jeff:保存目录last:%s\n\n",str);
- }
- UINT ImportPhotoThread( LPVOID lpParameter )
- {
- ImportPhoto *pThis=(ImportPhoto*)lpParameter;
- pThis->m_progress .SetRange (0, pThis->m_pArray->GetSize ());
- CString filename, filename2;
- CString temp;
- int pos;
- BOOL bNeedGet;
- CString temp2;
- int fileno;
- if(pThis->m_pArray2)
- {
- WriteTextLog("pThis->m_pArray2");
- if(pThis->m_bAddname)
- {
- WriteTextLog("pThis->m_bAddname");
- for(int i=0; i<pThis->m_pArray->GetSize (); i++)
- {
- filename=pThis->m_pArray->ElementAt (i);
- temp=filename.Right (filename.GetLength ()-filename.ReverseFind ('\\')-1);
- pos=temp.Find (".");
- temp=temp.Left(pos);
- temp+="("+pThis->m_name+",";
- temp2=pThis->m_pArray2->ElementAt (i)+").jpg";
- FilterFileName(temp2);
- // Jeff.add:拷贝文件失败,未做处理,最起码要日志记录失败原因;
- ::CopyFile (filename, pThis->m_savepath+temp+temp2, pThis->m_bOverWrite==0);
- WriteTextLog("pThis->m_bAddname:%s->%s", filename, pThis->m_savepath+temp+temp2);
- pThis->m_progress.SetPos (i+1);
- }
- }
- else
- {
- WriteTextLog("!pThis->m_bAddname");
- for(int i=0; i<pThis->m_pArray->GetSize (); i++)
- {
- filename=pThis->m_pArray->ElementAt (i);
- filename2=pThis->m_pArray2->ElementAt (i);
- pos=filename2.Find (";");
- while(pos!=-1)
- {
- temp=filename2.Left (pos);
- FilterFileName(temp);
- filename2=filename2.Right (filename2.GetLength ()-pos-1);
- pos=filename2.Find (";");
- ::CreateDirectory (pThis->m_savepath+temp, NULL);
- pThis->MyCopyFile (filename, pThis->m_savepath+temp+filename.Right (filename.GetLength ()-filename.ReverseFind ('\\')), pThis->m_bOverWrite==0);
- temp2=filename.Right (filename.GetLength ()-filename.ReverseFind ('\\')-1);
- int pos2=temp2.Find (".");
- if(pos2!=-1)
- {
- temp2=temp2.Left (pos2);
- CString filename2;
- }
- }
- temp=filename2;
- FilterFileName(temp);
- ::CreateDirectory (pThis->m_savepath+temp, NULL);
- pThis->MyCopyFile (filename, pThis->m_savepath+temp+filename.Right (filename.GetLength ()-filename.ReverseFind ('\\')), pThis->m_bOverWrite==0);
- temp2=filename.Right (filename.GetLength ()-filename.ReverseFind ('\\')-1);
- pos=temp2.Find (".");
- if(pos!=-1)
- {
- temp2=temp2.Left (pos);
- }
- pThis->m_progress.SetPos (i+1);
- }
- }
- }
- else if(pThis->m_pDesArray)
- {
- WriteTextLog("pThis->m_pDesArray");
- for(int i=0; i<pThis->m_pArray->GetSize (); i++)
- {
- filename=pThis->m_pArray->ElementAt (i);
- if(pThis->m_mode==2)
- {
- temp=filename.Right (filename.GetLength ()-filename.ReverseFind ('\\')-1);
- pos=temp.Find (".");
- bNeedGet=1;
- if(bNeedGet)// && (g_serverbak!="localserver"))
- filename2.Format("%s%03d.jpg",pThis->m_savepath, pThis->GetFileNo(pThis->m_calnopath) );
- else
- filename2.Format("%s%s.jpg",pThis->m_savepath, temp );
- pThis->MyCopyFile(filename, filename2, pThis->m_bOverWrite==0);
- }
- else
- pThis->MyCopyFile (filename, pThis->m_pDesArray->ElementAt (i), pThis->m_bOverWrite==0);
- pThis->m_progress.SetPos (i+1);
- }
- }
- else
- {
- WriteTextLog("!pThis->m_pDesArray");
- for(int i=0; i<pThis->m_pArray->GetSize (); i++)
- {
- filename=pThis->m_pArray->ElementAt (i);
- if(pThis->m_mode==2)
- {
- CString ext=filename.Right (filename.GetLength ()-filename.ReverseFind ('.')-1);
- if(0)//g_serverbak=="localserver")
- {
- temp=filename.Right (filename.GetLength ()-filename.ReverseFind ('\\')-1);
- filename2.Format("%s%s",pThis->m_savepath, temp);
- }
- else
- {
- fileno=pThis->GetFileNo(pThis->m_calnopath);
- filename2.Format("%s%03d.%s",pThis->m_savepath, fileno, ext);
- }
- pThis->MyCopyFile(filename, filename2, pThis->m_bOverWrite==0);
- }
- else
- {
- if(pThis->m_bBeautifySkinFrom)//修片导入
- {
- temp=pThis->m_savepath+filename.Right (filename.GetLength ()-filename.ReverseFind ('\\')-1);
- pos=temp.ReverseFind ('.');
- if(pos==-1)continue;
- temp=temp.Left (pos);
- pos=0;
- filename2.Format ("%s.jpg", temp);
- pos=2;
- while(::PathFileExists (filename2))
- {
- filename2.Format ("%s-%d.jpg", temp, pos);
- pos++;
- }
- pThis->MyCopyFile (filename, filename2, pThis->m_bOverWrite==0);
- }
- else
- {
- if(pThis->m_bOrigin)//原片导出
- {
- temp=filename.Right (filename.GetLength ()-filename.ReverseFind ('\\')-1);
- pos=temp.Find (".");
- if(pos==-1)continue;
- temp=temp.Left (pos);
- pThis->MyCopyFile (filename, pThis->m_savepath+filename.Right (filename.GetLength ()-filename.ReverseFind ('\\')-1), pThis->m_bOverWrite==0);
- }
- else
- pThis->MyCopyFile (filename, pThis->m_savepath+filename.Right (filename.GetLength ()-filename.ReverseFind ('\\')-1), pThis->m_bOverWrite==0);
- }
- }
- pThis->m_progress.SetPos (i+1);
- }
- }
- pThis->PostMessage (WM_CLOSE, 0, 0);
- return 1;
- }
- BOOL ImportPhoto::OnInitDialog()
- {
- CDialog::OnInitDialog();
- if(m_bCopyToLocal)
- SetDlgItemText(IDC_STATIC1, "客照缓存中, 请稍候...");
- else if(m_mode==1)
- SetDlgItemText(IDC_STATIC1, "正在导出客照, 请稍候...");
- if(beginno!=-1 && beginno!=0)
- {
- m_bautono=0;
- }
- /*
- #ifdef ENTERPRISE_VERSION
- if(m_bSaveUploadTask)
- {
- ZipTypeDlg dlg;
- dlg.DoModal ();
- m_sel=dlg.m_sel ;
- }
- #endif*/
- // m_fp.Open ("c:\\1.txt", CFile::modeCreate|CFile::modeWrite);
- // g_filecount=0;
- // TODO: Add extra initialization here
- AfxBeginThread((AFX_THREADPROC)ImportPhotoThread,(LPVOID)this );
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void SaveTaskPath(CString pathname)
- {
- return;
- CString path=g_path1+"\\taskpath.dat";
- CStringArray array;
- CFile fp;
- if(::PathFileExists (path))
- {
- try
- {
- int trycount=5;
- while(1)
- {
- if(fp.Open (path, CFile::modeRead|CFile::shareExclusive))break;
- fp.Close ();
- trycount--;
- if(trycount==0)break;
- ::Sleep (1000);
- }
- if(trycount==0)
- {
- if(::PathFileExists (path))return;
- }
- CArchive ar(&fp, CArchive::load);
- array.Serialize (ar);
- fp.Close ();
- }
- catch(...)
- {
- fp.Close ();
- // AfxMessageBox("读异常");
- }
- }
- array.Add (pathname);
- try
- {
- int trycount=5;
- while(1)
- {
- if(fp.Open (path, CFile::modeCreate|CFile::modeWrite|CFile::shareExclusive))break;
- fp.Close ();
- trycount--;
- if(trycount==0)break;
- ::Sleep (1000);
- }
- if(trycount==0)
- {
- // AfxMessageBox("打开失败2");
- return;
- }
- CArchive ar(&fp, CArchive::store);
- array.Serialize (ar);
- ar.Close();
- fp.Close ();
- }
- catch(...)
- {
- // AfxMessageBox("写异常");
- fp.Close ();
- }
- }
- void ImportPhoto::OnClose()
- {
- // TODO: Add your message handler code here and/or call default
- if(m_nphototype<0 || m_nphototype>3 )
- {
- CDialog::OnOK ();
- return;
- }
- if( m_uploadtaskarray.GetSize ()<=10)
- {
- CDialog::OnOK ();
- return;
- }
- #ifdef ENTERPRISE_VERSION
- if(m_bSaveUploadTask)
- {
- CString m_rule= g_cominfoarraylocal.ElementAt(0).ElementAt(116);
- CString m_header,m_left,m_right,m_currule;
- CStringArray rulearray;
- if(m_nphototype==0)
- {
- m_header="type0@:";
- }
- else if(m_nphototype==1)
- {
- m_header="type1@:";
- }
- else if(m_nphototype==2)
- {
- m_header="type2@:";
- }
- else if(m_nphototype==3)
- {
- m_header="type3@:";
- }
- int pos=m_rule.Find (m_header);
- if(pos!=-1)
- {
- m_left=m_rule.Left (pos);
- m_rule=m_rule.Right (m_rule.GetLength ()-pos);
- m_rule.Delete (0, m_header.GetLength ());
- pos=m_rule.Find ("@:");
- if(pos!=-1)
- {
- m_right=m_rule.Right (m_rule.GetLength ()-pos+5);
- m_rule=m_rule.Left (pos-5);
- }
- m_currule=m_rule;m_rule.Empty ();
- m_currule.TrimLeft ("%$");
- m_currule.TrimRight ("%$");
- if(m_currule.Find ("%$")!=-1)
- {
- pos=m_currule.Find ("%$");
- while(pos!=-1)
- {
- if(m_currule.Left (pos)!="")rulearray.Add(m_currule.Left (pos));
- m_currule=m_currule.Right (m_currule.GetLength ()-pos-2);
- pos=m_currule.Find ("%$");
- }
- }
- if(m_currule!="")rulearray.Add(m_currule);
- }
- for(int i=0; i<rulearray.GetSize (); i++)
- {
- m_currule=rulearray.ElementAt (i);
- pos=m_currule.Find ("->");
- if(pos==-1)continue;
- m_left=m_currule.Left (pos);
- m_right=m_currule.Right(m_currule.GetLength ()-pos-2);
- CString curdomain,curdomain2;
- if(m_branch!="")
- {
- curdomain=GetDomainFromBranch(m_branch);
- curdomain2=GetDomainFromBranch(g_brancharray.ElementAt (g_brancharray.GetSize ()-1).ElementAt (0));
- }
- else if(g_branchname!="")
- {
- curdomain=GetDomainFromBranch(g_branchname);
- curdomain2=GetDomainFromBranch(g_brancharray.ElementAt (g_brancharray.GetSize ()-1).ElementAt (0));
- }
- else
- {
- curdomain=GetDomainFromBranch(g_brancharray.ElementAt (g_brancharray.GetSize ()-1).ElementAt (0));
- curdomain2=curdomain;
- }
- CString domainleft=GetDomainFromBranch(m_left);
- if(curdomain!=domainleft)
- {
- continue;
- }
- CString domainright=GetDomainFromBranch(m_right);
- if(domainleft.Find(".ly.com")==-1 || domainright.Find(".ly.com")==-1)
- {
- continue;
- }
- if(curdomain2==domainright)
- {
- continue;
- }
- MyLock lock("uploadtaskaccess");
- m_uploadtaskarray.SetAt (1, domainright);//目的地
- m_uploadtaskarray.SetAt (2, domainleft);//文件夹加上域名
- m_uploadtaskarray.SetAt (3, m_sel);
- CFile fp;
- CString pathdir=m_savepath+"uploadtask";
- if(m_id!="")
- {
- int pos=pathdir.Find (m_id);
- pos+=m_id.GetLength ();
- int pos2=pathdir.ReverseFind ('\\');
- pathdir=pathdir.Left (pos)+pathdir.Right (pathdir.GetLength ()-pos2);
- }
- CString path;
- int taskpos=1;
- path.Format ("%s%d.dat", pathdir, taskpos);
- CString dir=path.Left (path.ReverseFind ('\\')+1);
- pathdir=g_path1+"\\上传任务\\";
- ::CreateDirectory(pathdir, NULL);
- path.Format ("%s%d.dat", pathdir, taskpos);
- while(::CheckFileExist (path))
- {
- taskpos++;
- path.Format ("%s%d.dat", pathdir, taskpos);
- }
- fp.Open (path, CFile::modeCreate|CFile::modeWrite);
- CArchive ar(&fp, CArchive::store);
- m_uploadtaskarray.SetAt(4, dir);
- m_uploadtaskarray.Serialize (ar);
- ar.Close();
- fp.Close ();
- // SaveTaskPath(path);
- }
- }
- #endif
- // CString ss;
- //ss.Format ("cc:%d", g_filecount);MessageBox(ss);m_fp.Close ();
- CDialog::OnOK();
- }
- // file1原文件;
- // file2目标文件;
- void ImportPhoto::MyCopyFile(CString file1, CString file2, BOOL bOverWrite)
- {
- WriteTextLog("MyCopyFile:run:%s->%s",file1, file2);
- if(::PathFileExists (file1)==0)
- {
- return;
- }
- if(m_bOfmat)
- {
- WriteTextLog("MyCopyFile:m_bOfmat");
- CString file1bak=file1;
- CString file2bak=file2;
- file1bak=file1bak.Left (file1bak.GetLength ()-3);
- file2bak=file2bak.Left (file2bak.GetLength ()-3);
- file1bak+="jpg";
- file2bak+="jpg";
- CString src=file1bak;
- CString des=file2bak;
- src.Replace(".jpg", ".raw");
- des.Replace(".jpg", ".raw");
- ::CopyFile (src, des, bOverWrite);
- src=file1bak;
- des=file2bak;
- src.Replace(".jpg", ".nef");
- des.Replace(".jpg", ".nef");
- ::CopyFile (src, des, bOverWrite);
- src=file1bak;
- des=file2bak;
- src.Replace(".jpg", ".cr2");
- des.Replace(".jpg", ".cr2");
- ::CopyFile (src, des, bOverWrite);
- }
- if(m_nphototype==0 ||m_nphototype==1 || m_nphototype==2 || m_nphototype==3)
- {
- CString str=file2;
- CString spath=str.Left (str.ReverseFind ('\\')+1);
- CString mpath=spath;
- spath+="s";
- spath+=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
- mpath+="m";
- mpath+=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
- ::DeleteFile (spath);
- ::DeleteFile (mpath);
- }
- if(m_nOutputSize)
- {
- WriteTextLog("MyCopyFile:m_nOutputSize");
- file1.MakeLower ();
- if(file1.Right (3)=="jpg")
- {
- Image *img=NULL;
- ::LoadImageFromBuf (&img, file1);
- if(img==NULL)
- {
- if(::CopyFile (file1, file2, bOverWrite)==0)
- {
- CString str;
- str=file1;
- int pos=str.ReverseFind ('\\');
- if(pos!=-1)
- str=str.Right (str.GetLength ()-pos-1);
- AfxMessageBox("拷贝失败"+str+"请重新导入此文件!");
- }
- }
- else if(img->GetWidth()==0)
- {
- if(::CopyFile (file1, file2, bOverWrite)==0)
- {
- CString str;
- str=file1;
- int pos=str.ReverseFind ('\\');
- if(pos!=-1)
- str=str.Right (str.GetLength ()-pos-1);
- AfxMessageBox("拷贝失败"+str+"请重新导入此文件!!");
- }
- }
- else
- {
- int newsize=m_nOutputSize;
- if(img->GetWidth()>newsize || img->GetHeight()>newsize)
- {
- CRect rc(0,0,newsize,newsize);
- RectFitDes(img->GetWidth(), img->GetHeight(), rc);
- Image *simg= img->GetThumbnailImage(rc.Width (), rc.Height (), NULL, NULL);
- Graphics graphic(simg);//防止GetThumbnailImage影响质量
- graphic.DrawImage(img, 0,0,simg->GetWidth(), simg->GetHeight() );
- delete img;
- ::SaveImageToFile(simg, file2);
- delete simg;
- }
- else
- {
- if(::CopyFile (file1, file2, bOverWrite)==0)
- {
- CString str;
- str=file1;
- int pos=str.ReverseFind ('\\');
- if(pos!=-1)
- str=str.Right (str.GetLength ()-pos-1);
- AfxMessageBox("拷贝失败"+str+"请重新导入此文件!!!");
- }
- }
- }
- }
- else
- {
- if(::CopyFile (file1, file2, bOverWrite)==0)
- {
- CString str;
- str=file1;
- int pos=str.ReverseFind ('\\');
- if(pos!=-1)
- str=str.Right (str.GetLength ()-pos-1);
- AfxMessageBox("拷贝失败"+str+"请重新导入此文件!!!!");
- }
- }
- }
- else
- {
- WriteTextLog("!MyCopyFile:m_nOutputSize");
- if(::CopyFile (file1, file2, bOverWrite)==0)
- {
- CString str;
- str=file1;
- int pos=str.ReverseFind ('\\');
- if(pos!=-1)
- str=str.Right (str.GetLength ()-pos-1);
- AfxMessageBox("拷贝失败"+str+"请重新导入此文件!!!!!");
- }
- //
- if(m_bCopyToLocal)//选片缓存
- {
- WriteTextLog("MyCopyFile:m_bCopyToLocal");
- CString path=file2;
- CString spath=path.Left (path.ReverseFind ('\\')+1);
- spath+="s";
- // CString temp=path.Right (path.GetLength ()-path.ReverseFind ('\\')-1);
- spath+=path.Right (path.GetLength ()-path.ReverseFind ('\\')-1);
- //if(!CheckFileExist (spath))
- {
- Image *pImg=NULL;
- ::LoadImageFromBuf(&pImg, path);
- if(pImg==NULL)return;
- if(pImg->GetWidth()==0)return;
- CRect rc(0,0,100,90);
- RectFitDes(pImg->GetWidth(), pImg->GetHeight(), rc);
- Image *simg=pImg->GetThumbnailImage(rc.Width (), rc.Height (), NULL, NULL);
- if(simg==NULL)return;
- Graphics graphic(simg);//防止GetThumbnailImage影响质量
- graphic.Clear(Color(255,255,255,255));
- graphic.DrawImage(pImg, 0,0,simg->GetWidth(), simg->GetHeight() );
- ///////////////////////////////
- UINT totalBufferSize;
- UINT numProperties;
- pImg->GetPropertySize(&totalBufferSize, &numProperties);
- // Allocate the buffer that will receive the property items.
- PropertyItem* pAllItems = (PropertyItem*)malloc(totalBufferSize);
- // Fill the buffer.
- pImg->GetAllPropertyItems(totalBufferSize, numProperties, pAllItems);
- // Print the id data member of each property item.
- for(UINT j = 0; j < numProperties; ++j)
- {
- if(PropertyTagOrientation==pAllItems[j].id)
- {
- short* ptrLong = (short*)(pAllItems[j].value);
- int ret=(int)*ptrLong;
- // CString str;
- // str.Format ("%d", ret);
- // AfxMessageBox(str);
- if(ret==8)
- {
- simg->RotateFlip( Rotate270FlipNone );
- }
- else if(ret==6)
- {
- simg->RotateFlip( Rotate90FlipNone );
- }
- break;
- }
- }
- free(pAllItems);
- ///////////////////////////////
- ::SaveImageToFile (simg, spath);
- delete simg;
- delete pImg;
- }
- }//选片缓存
- }
- file2.MakeLower ();
- if(m_mode!=1 && file2.Right (3)=="jpg")
- {
- CString path=file2.Left (file2.ReverseFind ('\\'));
- path.TrimRight ("\\");path+="\\";
- path+="modifytime";
- CStdioFile fp;
- if(::PathFileExists (path))
- {
- fp.Open (path,CFile::modeWrite);
- fp.WriteString (g_date);
- fp.Close ();
- }
- else
- {
- fp.Open (path,CFile::modeCreate|CFile::modeWrite);
- fp.WriteString (g_date);
- fp.Close ();
- }
- }
- #ifdef ENTERPRISE_VERSION
- if(m_bSaveUploadTask)
- {
- if(m_id!="")
- {
- if(file2.Right (3)=="jpg")
- {
- int pos=file2.Find (m_id);
- pos+=m_id.GetLength ();
- int pos2=file2.ReverseFind ('\\');
- CString jd;
- if(pos2>pos)
- {
- jd=file2.Mid(pos+1, pos2-pos-1);
- }
- CString task;
- if(jd!="")
- task=jd+"\\"+file2.Right (file2.GetLength ()-pos2-1);
- else
- task=file2.Right (file2.GetLength ()-pos2-1);
- m_uploadtaskarray.Add (task);
- m_uploadtaskarray.Add ("");
- }
- }
- else
- {
- if(file2.Right (3)=="jpg")
- {
- m_uploadtaskarray.Add (file2.Right (file2.GetLength ()-m_savepath.GetLength ()));
- m_uploadtaskarray.Add ("");
- }
- }
- }
- #endif
- }
- //*
|