资源简介
在c#中利用gdal对图像格式进行相互转换,文件包括整个项目,可以在vs中直接代开,具体代码明确,已经经过测试。
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
//langyue_wu@163.com
namespace ImageConvert
{
class ChangeImageClass
{
private string _dataPath;
private string _savePath;
private int _pathIndex;
private string _fileExtension;
private string _pixFormat;
private float _ResolutionH;
private float _ResolutionV;
private int _fileCount;
private int _fileInc;
public delegate void ShowMessageHander(string strMessage);
public event ShowMessageHander ShowMessageEvent;
public delegate void ShowExceptionHander(string strMessage);
public event ShowExceptionHander ShowExceptionEvent;
public delegate void AfterWorkHander();
public event AfterWorkHander AfterWorkEvent;
public delegate void ShowProgressHander(int progressNum int totalNum);
public event ShowProgressHander ShowProgressEvent;
public ChangeImageClass(string dataPath string savePath string fileExtension string pixFormat float ResolutionH float ResolutionV)
{
_dataPath = dataPath;
_savePath = savePath;
_fileExtension = fileExtension;
_pixFormat = pixFormat;
_ResolutionH = ResolutionH;
_ResolutionV = ResolutionV;
}
public void MainProcess()
{
try
{
DirectoryInfo dirParent = Directory.GetParent(_dataPath);
_pathIndex = dirParent.FullName.Length;
_savePath = Path.Combine(_savePath _dataPath.Substring(_pathIndex).TrimStart(‘\\‘) + “转换后“);
_pathIndex = _dataPath.Length;
DirectoryInfo dirInfo = new DirectoryInfo(_dataPath);
_fileCount = dirInfo.GetFiles(“*.*“ SearchOption.AllDirectories).Length;
ShowMessageEvent(string.Format(“总文件数:{0}“ _fileCount));
_fileInc = 0;
ListFolder(dirInfo true);
ShowMessageEvent(string.Format(“处理文件数:{0}“ _fileInc));
AfterWorkEvent();
}
catch (Exception ee)
{
//盘符目录
ShowExceptionEvent(string.Format(“【异常】{0}“ ee.Message));
}
}
///
/// 递归目录
///
/// 文件信息
/// 是否递归子项
private void ListFolder(FileSystemInfo fileInfo bool getChildren)
{
if (!fileInfo.Exists) return;//如果文件不存在,返回
DirectoryInfo dirInfo = fileInfo as DirectoryInfo;//转换成目录
if (dirInfo == null) return; //不是目录
if (getChildren)
{
DirectoryInfo[] dirs = dirInfo.G
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-09-12 20:26 ImageConvert\
目录 0 2013-09-12 20:36 ImageConvert\ImageConvert\
文件 10677 2013-09-12 20:54 ImageConvert\ImageConvert\ChangeImageClass.cs
文件 7675 2013-09-12 20:30 ImageConvert\ImageConvert\FormMain.cs
文件 16753 2013-09-12 20:30 ImageConvert\ImageConvert\FormMain.designer.cs
文件 253360 2013-09-12 20:30 ImageConvert\ImageConvert\FormMain.resx
文件 5744 2013-09-12 20:36 ImageConvert\ImageConvert\ImageConvert.csproj
文件 580 2012-12-12 00:58 ImageConvert\ImageConvert\ImageConvert.csproj.user
文件 474 2011-04-16 11:51 ImageConvert\ImageConvert\Program.cs
目录 0 2011-10-27 14:41 ImageConvert\ImageConvert\Properties\
文件 1203 2013-09-12 20:53 ImageConvert\ImageConvert\Properties\AssemblyInfo.cs
文件 2862 2012-12-12 00:58 ImageConvert\ImageConvert\Properties\Resources.Designer.cs
文件 5612 2011-04-16 11:50 ImageConvert\ImageConvert\Properties\Resources.resx
文件 1110 2012-12-12 00:58 ImageConvert\ImageConvert\Properties\Settings.Designer.cs
文件 249 2011-04-16 11:50 ImageConvert\ImageConvert\Properties\Settings.settings
目录 0 2013-09-12 21:47 ImageConvert\ImageConvert\bin\
文件 6447104 2011-04-16 11:50 ImageConvert\ImageConvert\gdal18.dll
文件 161862 2011-04-16 11:50 ImageConvert\ImageConvert\iPulse.ico
目录 0 2013-09-12 20:28 ImageConvert\ImageConvert\libs\
文件 7030 2011-04-16 11:50 ImageConvert\ImageConvert\libs\FileProcessClass.cs
文件 421200 2011-04-16 14:18 ImageConvert\ImageConvert\msvcp100.dll
文件 770384 2011-04-16 12:06 ImageConvert\ImageConvert\msvcr100.dll
目录 0 2011-10-27 14:41 ImageConvert\ImageConvert\obj\
目录 0 2011-10-27 14:41 ImageConvert\ImageConvert\obj\Debug\
文件 162428 2011-04-16 11:51 ImageConvert\ImageConvert\obj\Debug\ImageConvert.FormMain.resources
文件 180 2011-04-16 11:51 ImageConvert\ImageConvert\obj\Debug\ImageConvert.Properties.Resources.resources
文件 845 2011-04-16 11:51 ImageConvert\ImageConvert\obj\Debug\ImageConvert.csproj.GenerateResource.Cache
目录 0 2013-09-12 21:52 ImageConvert\ImageConvert\obj\Debug\TempPE\
文件 2251 2011-06-27 09:41 ImageConvert\ImageConvert\obj\ImageConvert.csproj.FileListAbsolute.txt
目录 0 2013-09-12 20:47 ImageConvert\ImageConvert\obj\Release\
文件 789 2013-09-12 20:29 ImageConvert\ImageConvert\obj\Release\DesignTimeResolveAssemblyReferences.cache
............此处省略13个文件信息
- 上一篇:C#连接数据库..
- 下一篇:基于C#的销售管理系统
评论
共有 条评论