C/C++和MFC的批处理特定文件

版权声明:转载请注明文章出处,否则不得转载! https://blog.csdn.net/hanxiaoyong_/article/details/83503230

转载请注明出处! 

实现一个文件夹下的特定格式文档,本文针对于基于对话框的CFileDialog的类来获得批保存的路径,

  利用CFileFind的的FindFile函数查找文档路径

virtual BOOL FindFile(LPCTSTR pstrName = NULL,DWORD dwUnused = 0);

参数:

pstrName以一个包含该文件的名称来找到指针。如果你传递pstrName空,的FindFile(*。*)做了通配符搜索.dwUnused保留作出的FindFile多态性与派生类。必须为0返回值非零如果成功,否则为0。为了获得更多的错误信息,调用的的Win32函数GetLastError函数函数函数备注在调用的的FindFile开始搜索该文件,调用FindNextFile检索后续文件您必须调用至少一次,然后再调用下面的属性成员函数任何FindNextFile :
 

CFileDialog dlg(TRUE,“bmp”,“*。bmp”);
        if(dlg.DoModal()== IDOK)
        {
            CString strTemp = dlg.GetPathName(); //得到批保存路径
            int t = 0;    
            t = strlen(strTemp);
            int pos = strTemp.ReverseFind('\\'); //查找最后一个\的位置;
            CString str_path = strTemp;
            str_path.Delete(位置+ 1,T);
            str_path.Replace(“\\”,“\\\\”); // //得到批保存路径
            CString tempPath = str_path; 

            CFile的文件;
             str_path + =“* .bmp”;
            CFileFind fl; 
            BOOL bF = fl.FindFile(str_path);      
            while(bF)  
            {        
                bF = fl.FindNextFile();  
                CString filePath = fl.GetFilePath(); //得到图像的路径
                
                CString fileName = fl.GetFileName(); //得到图像名
            
                file.Open(filePath,CFile :: modeRead); //只读设为模式  

///////////////////////////////////////到这已经可以打开所有bmp文件了///////////////////////////////////////////////////////


                dib1.Read(文件); //调用CDIB中的读取文件
                .Close();
                CWnd * pWnd = GetDlgItem(IDC_STATIC);
                CRect rect;
                pWnd - > GetClientRect(&rect); //获得控件区域的大小
                CDC * pDC = pWnd - > GetDC();
                int Width = rect.Width();
                int Height = rect.Height();
                dib1.Draw(PDC,(0,0),的的CSize(宽度,高度)); //调用CDib中的绘图函数
                CSize sizeImage = dib1.GetDimensions();
                int nWidth = sizeImage.cx;
                int nHeight = sizeImage.cy;
                int x,y;
                CSize sizeImageSave = dib1.GetDibSaveDim();
                int nSaveWidth = sizeImageSave.cx; //图像在内存中每一行象素占用的实际空间
                LPBYTE pImageData = dib1.m_lpImage; 
                for(y = 0; y <nHeight; y ++)
                {    
                    for(x = 0; x <nWidth; x ++)//对数化像素
                    {
                        (*(pImageData + y * nSaveWidth + x))=(int)(c * log(1.0 + *(pImageData + y * nSaveWidth +                                         x)));
                        
                    }
                }

猜你喜欢

转载自blog.csdn.net/hanxiaoyong_/article/details/83503230