首页 新闻 会员 周边 捐助

提取gif图片后动态图片变成静态的了

0
悬赏园豆:50 [已关闭问题] 关闭于 2011-10-17 13:49

代码如下:

string picurl = "http://www.ifanr.com/wp-content/uploads/2011/10/J1D2AYQV.gif";
string savepath=@"D:\test.gif";
string imgExt = picurl.Substring(picurl.LastIndexOf("."), picurl.Length - picurl.LastIndexOf("."));
WebRequest wreq = WebRequest.Create(picurl);
wreq.Timeout = 10000;
HttpWebResponse wresp = (HttpWebResponse)wreq.GetResponse();
Stream s = wresp.GetResponseStream();
System.Drawing.Image img = System.Drawing.Image.FromStream(s);
if (imgExt == ".gif")
{
img.Save(savepath, ImageFormat.Gif);
}
img.Dispose();
s.Dispose();

请教高人,为什么动成的gif图片保存为本地gif图片后成静态的了?

artwl的主页 artwl | 专家六级 | 园豆:16736
提问于:2011-10-17 11:57
< >
分享
所有回答(2)
0
                    using (WebClient wc = new WebClient())
{
wc.DownloadFile(picurl, savepath);
}
artwl | 园豆:16736 (专家六级) | 2011-10-17 13:49
0

你那是下载了第一帧的图,当然是静态的了。可以这样下载的。

 string picurl = "http://www.ifanr.com/wp-content/uploads/2011/10/J1D2AYQV.gif";
string savepath = @"D:\test.gif";
string imgExt = picurl.Substring(picurl.LastIndexOf("."), picurl.Length - picurl.LastIndexOf("."));

if (imgExt == ".gif")
{
using (WebClient wc = new WebClient())
{
try
{
wc.DownloadFile(picurl, savepath);
MessageBox.Show("文件下载成功!");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
LCM | 园豆:6876 (大侠五级) | 2011-10-17 14:04

谢谢,后来自己找到答案了

支持(0) 反对(0) artwl | 园豆:16736 (专家六级) | 2011-10-17 15:15
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册