private void pictureBox_Click(object sender, EventArgs e)
{
int picWidth = 0;
int picHeight = 0;
var location = (PictureBox)sender;
using (FileStream fs = new FileStream(location.ImageLocation, FileMode.Open, FileAccess.Read))
{
System.Drawing.Image image = System.Drawing.Image.FromStream(fs);
picWidth = image.Width;
picHeight = image.Height;
}
bigPicture.ImageLocation = location.ImageLocation;
bigPicture.Visible = true;
bigPicture.BackgroundImageLayout = ImageLayout.Stretch;
bigPicture.Size = new System.Drawing.Size(picWidth, picHeight);
bigPicture.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
bigPicture.BringToFront();
}
picturebox原比例展示图片
最新推荐文章于 2021-01-10 10:57:13 发布