调整GIF大小并保存动画?
问题描述:
我使用这个代码我写来调整我的图片,以适合我的PictureBox:调整GIF大小并保存动画?
//Creates a new Bitmap as the size of the window
Bitmap bmp = new Bitmap(this.Width, this.Height);
//Creates a new graphics to handle the image that is coming from the stream
Graphics g = Graphics.FromImage((Image)bmp);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
//Resizes the image from the stream to fit our windows
g.DrawImage(Properties.Resources.loading, 0, 0, this.Width, this.Height);
this.Image = (Image)bmp;
运行完美!
唯一problam是,当我尝试调整一个GIF ......它会调整,但我失去了动画...
任何修复是什么?
答
您应该简单地将PictureBox的SizeMode
设置为StretchImage
以使PictureBox为您拉伸图像。