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

推荐订阅源

J
Java Code Geeks
爱范儿
爱范儿
Attack and Defense Labs
Attack and Defense Labs
量子位
The GitHub Blog
The GitHub Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Scott Helme
Scott Helme
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 叶小钗
C
Cybersecurity and Infrastructure Security Agency CISA
S
Securelist
S
Schneier on Security
C
Cisco Blogs
B
Blog RSS Feed
Cisco Talos Blog
Cisco Talos Blog
Last Week in AI
Last Week in AI
WordPress大学
WordPress大学
腾讯CDC
酷 壳 – CoolShell
酷 壳 – CoolShell
罗磊的独立博客
Y
Y Combinator Blog
Latest news
Latest news
T
Tailwind CSS Blog
Jina AI
Jina AI
宝玉的分享
宝玉的分享
人人都是产品经理
人人都是产品经理
C
CERT Recently Published Vulnerability Notes
D
Darknet – Hacking Tools, Hacker News & Cyber Security
L
Lohrmann on Cybersecurity
The Cloudflare Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Security Blog
Microsoft Security Blog
H
Help Net Security
P
Palo Alto Networks Blog
V
V2EX
博客园_首页
D
Docker
T
Threat Research - Cisco Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Vulnerabilities – Threatpost
月光博客
月光博客
D
DataBreaches.Net
Stack Overflow Blog
Stack Overflow Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Know Your Adversary
Know Your Adversary
L
LangChain Blog
The Hacker News
The Hacker News
K
Kaspersky official blog
The Register - Security
The Register - Security
NISL@THU
NISL@THU

博客园 - 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;
        }