通过WebRequest下载的Gif图片,为什么是一帧?
代码如下:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(imgModel.SourceUrl); request.Referer = Request.UrlReferrer.ToString(); request.UserAgent = Request.UserAgent; WebResponse response = request.GetResponse(); Stream imgStream = response.GetResponseStream(); if (imgStream != null) { Image img = Image.FromStream(imgStream, true, true); string extension = Common.GetImageFormat(img.RawFormat); //Bitmap bitmap = new Bitmap(img);//这里用bitmap方式保存也不行 //bitmap.Save(Request.MapPath("/Images/" + Guid.NewGuid().ToString()) + extension, img.RawFormat); img.Save(Request.MapPath("/Images/" + Guid.NewGuid().ToString()) + extension, img.RawFormat); WriteAsCrossDomain(Request["jsoncallback"], string.Format("'宽:{0},高:{1}'", img.Width, img.Height)); img.Dispose(); //bitmap.Dispose(); }