Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resize GIF and save animation?

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?

like image 879
Danpe Avatar asked Oct 17 '25 05:10

Danpe


1 Answers

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

like image 86
SLaks Avatar answered Oct 19 '25 22:10

SLaks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!