惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
月光博客
月光博客
S
SegmentFault 最新的问题
量子位
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 司徒正美
博客园 - Franky
Google DeepMind News
Google DeepMind News
Recent Announcements
Recent Announcements
B
Blog RSS Feed
C
Check Point Blog
The Cloudflare Blog
M
MIT News - Artificial intelligence
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
F
Fortinet All Blogs
Hugging Face - Blog
Hugging Face - Blog
博客园 - 叶小钗
V
Visual Studio Blog
V
V2EX
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 聂微东
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - Magicam

jquery easyui 扩展验证 vs2010 安装 Ajax Control Toolkit Backing up the tail mysql 1449 : The user specified as a definer ('root'@'%') does not exist 解决方法 WInform CMD command Mysql中的数据导入SQLServer2000 VS2010安装SP1后无法安装VS2010 SDK Vs2008调试Silverlight时,出现“未安装silverlight托管调试包” js 取时间代码 Sys.ArgumentOutOfRangeException: Value must be an integer 错误的原因 iframe - Magicam wia Kodak 扫描仪应用 winform - Magicam js实现: e.keycode详解 jquery 无法设置selected属性,未指明的错误 Mysql存储过程游标循环操作 JQuery ListBox间移动和ListBox内上下移动 Visual Studio 2010 安装“deffactory.dat can not open” 的解决办法 - Magicam js 实现2列 div 自适应高度 - Magicam NetTiers模板属性说明 NHibernate配置引发的异常 - Magicam - 博客园
Tif文件转换成GIF列表 - Magicam - 博客园
Magicam · 2010-08-20 · via 博客园 - Magicam

代码

 /// <summary>
        
/// 将TIF文件转换为GIF文件列表
        
/// </summary>
        
/// <param name="fileName">要转换的TIF文件</param>        
        
/// <returns>转换后生成的GIF文件路径</returns>
        public static IList<string> ConvertTifToGif(string fileName)
        {
            IList
<string> list = new List<string>();string dic = AppDomain.CurrentDomain.BaseDirectory + "\\tempgif\\";if (!Directory.Exists(dic))
            {
                Directory.CreateDirectory(dic);
            }
if (string.IsNullOrEmpty(fileName))
            {
                
throw new ArgumentException("转换的TIF文件路径不能为空");
            }

            FileInfo file 

= new FileInfo(fileName);if (!file.Exists)
            {
                
throw new FileNotFoundException("待转换的TIF文件不存在");
            }

            Image imgObj 

= Image.FromFile(file.FullName);//Image imgObj = imgObj2.GetThumbnailImage(imgObj2.Width / 3 * 2, imgObj2.Height / 3 * 2, null, IntPtr.Zero); //Image.FromFile(file.FullName);

            Guid objGuid 
= (Guid)imgObj.FrameDimensionsList.GetValue(0);

            FrameDimension objDimension 

= new FrameDimension(objGuid);
            
int totalImage = imgObj.GetFrameCount(objDimension);for (int index = 0; index < totalImage; index++)
            {
                
string gifPath = dic + file.Name.Substring(0, file.Name.LastIndexOf('.')) + "_" + index + ".gif";if (File.Exists(gifPath))
                {
                    File.Delete(gifPath);
                }
//EncoderParameter en = new EncoderParameter();

                imgObj.SelectActiveFrame(objDimension, index);
                imgObj.Save(gifPath, ImageFormat.Gif);
                FileInfo item 
= new FileInfo(gifPath);
                list.Add(
"tempgif\\" + item.Name);
            }
return list;
        }