【发布时间】:2011-12-09 00:42:53
【问题描述】:
我从网站上获取了一张gif图片,但是保存后变成静态图片,我的代码是:
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?
-
不要不将其转换为
Image,而是将二进制流直接保存到您的文件中。