如标题所示,我看不到图像为什么没有改变尺寸。谁能看到?
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Title = "Open bitmap or jpeg.";
//dlg.Filter = "jpg files (*.jpg);*.jpg;*.* | bmp files (*.bmp); *.bmp";
if (dlg.ShowDialog() == DialogResult.OK)
{
this.pictureBoxMap1.Image = new Bitmap(dlg.OpenFile());
Image newImage = this.pictureBoxMap1.Image;
pictureBoxMap1.Height = newImage.Height;
pictureBoxMap1.Width = newImage.Width;
}
dlg.Dispose();
最佳答案
OpenFileDialog fd = new OpenFileDialog();
DialogResult r = fd.ShowDialog();
if (r == System.Windows.Forms.DialogResult.OK)
{
pictureBoxMap1.Image = Bitmap.FromFile(fd.FileName);
pictureBoxMap1.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBoxMap1.Refresh();
}
尝试这个。
关于c# - 如何将图像更改为图片框的大小?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13869824/