调整 GIF 大小并保存动画?

发布于 2024-11-30 13:39:12 字数 678 浏览 7 评论 0原文

我正在使用我编写的代码来调整图像大小以适合我的 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 大小时...它调整了大小但我丢失了动画...

对此有解决办法吗?

I'm using this code i wrote to resize my images to fit my 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;

Works perfect !

The only problam is when im trying to resize a GIF... it resizes but i lose the animation...

Any fix for that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

望喜 2024-12-07 13:39:12

您只需将 PictureBox 的 SizeMode 设置为 StretchImage 即可让 PictureBox 为您拉伸图像。

You should simply set the PictureBox's SizeMode to StretchImage to make the PictureBox stretch the image for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文