我正在使用我编写的代码来调整我的图像大小以适应我的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的大小时…它可以调整大小,但我失去了动画效果...
有什么办法解决这个问题吗?
发布于 2011-08-22 22:21:20
您只需将图片框的SizeMode
设置为StretchImage
,即可使PictureBox为您拉伸图像。
https://stackoverflow.com/questions/7148868
复制相似问题