在asp.net中上传GIF图像流

时间:2016-07-12 05:34:46

标签: c# asp.net image animation gif

这是我在数据库中上传图片的代码我在服务器端上传图像时调整图像大小。



System.Drawing.Image ImageFile = System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream);
            Bitmap btmFile = new Bitmap(ImageFile, 1366, 768);
            MemoryStream stream = new MemoryStream();
            stream.Position = 0;
            switch (ImageFormat)
            {
                case "jpg":
                    btmFile.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                    break;
                case "png":
                    btmFile.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                    break;
                case "gif":
                    btmFile.Save(stream, System.Drawing.Imaging.ImageFormat.Gif);
                    break;
            }
            Stream fs = stream;
            BinaryReader br = new BinaryReader(fs);
            Byte[] bytes = br.ReadBytes((Int32)fs.Length);




它运行正常,但问题是当我在恢复到图像查看器时上传动画GIF时帧已经消失,动画也是如此

0 个答案:

没有答案