c# - 调整 GIF 大小并保存动画?

标签 c# .net graphics picturebox animated-gif

我正在使用我编写的这段代码来调整图像大小以适合我的 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/

相关文章:

c# - 将 DataTable 转换为 List<T>,其中 List 的类是 Dynamic

c# - 如何在 C# 中创建一个全局对象?

c# - 在 ClassLibrary 中使用资源 (resx),无需重新编译即可更改

unity3d - HDR输出的当前状态

java - Java中的透明圆形对话框

c# - 在 C# 中更改 Jpeg 文件的大小

c# Regex.Matches 具有多个匹配结果的问题

c++ - 如何在 AMD 显卡上获取 GPU 负载百分比和 GPU 温度

c# - 在 Racket 上实现 RC4

c# - 将 C# 桌面应用程序与 Rails 网络应用程序链接起来