利用OpenFileDialog顯示圖片於pictureBox1
pictureBox1的寬及高決定於圖片來源大小


private void btnOpen_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "BMP(*.BMP)|*.bmp|" + "所有檔案|*.*";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
pictureBox1.Width = Image.FromFile(openFileDialog.FileName).Width;
pictureBox1.Height = Image.FromFile(openFileDialog.FileName).Height;
pictureBox1.Image = Image.FromFile(openFileDialog.FileName);
}
}

阿倫 發表在 痞客邦 PIXNET 留言(0) 人氣()