我正在使用我编写的这段代码来调整图像大小以适合我的 PictureBox:
//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;
工作完美!
唯一的问题是当我尝试调整 GIF 大小时...它调整了大小但我失去了动画...
有什么解决办法吗?
最佳答案
您只需将 PictureBox 的 SizeMode
设置为 StretchImage
即可让 PictureBox 为您拉伸(stretch)图像。
关于c# - 调整 GIF 大小并保存动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7148868/