3

正如标题所说,我不明白为什么图像没有改变大小。任何人都可以看到吗?

{
            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();
4

1 回答 1

3
        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();
       }

试试这个。

于 2012-12-13T22:48:09.443 回答