我正在使用我编写的代码来调整我的图片大小以适应我的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的大小时......它调整大小但我失去了动画......
对此有何解决方法?
答案 0 :(得分:3)
您只需将PictureBox的SizeMode
设置为StretchImage
即可让PictureBox为您拉伸图像。