为 PictureBox 打开图像 - C#
Open Image for PictureBox - C#
我不知道这里出了什么问题!它会打开 "OpenFileDialog",它会在 PictureBox 中加载图像,但图像不会被拉伸。请帮忙!谢谢:)
private void browsePic_Click(object sender, EventArgs e)
{
openPicture.Filter = "PNG|*.png|JPG|*.jpg;*.jpeg";
if(openPicture.ShowDialog() == DialogResult.OK)
{
pictureBox2.BackgroundImageLayout = ImageLayout.Stretch;
pictureBox2.Image = new Bitmap(openPicture.FileName);
}
}
根据需要更改 PictureBox 的 SizeMode-属性。
https://msdn.microsoft.com/de-de/library/system.windows.forms.picturebox.sizemode(v=vs.110).aspx
PictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
我不知道这里出了什么问题!它会打开 "OpenFileDialog",它会在 PictureBox 中加载图像,但图像不会被拉伸。请帮忙!谢谢:)
private void browsePic_Click(object sender, EventArgs e)
{
openPicture.Filter = "PNG|*.png|JPG|*.jpg;*.jpeg";
if(openPicture.ShowDialog() == DialogResult.OK)
{
pictureBox2.BackgroundImageLayout = ImageLayout.Stretch;
pictureBox2.Image = new Bitmap(openPicture.FileName);
}
}
根据需要更改 PictureBox 的 SizeMode-属性。 https://msdn.microsoft.com/de-de/library/system.windows.forms.picturebox.sizemode(v=vs.110).aspx
PictureBox.SizeMode = PictureBoxSizeMode.StretchImage;