我想在上傳後調整圖像大小,但它不起作用C# - 上傳後調整圖像大小
怎麼了?
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
if (open.ShowDialog() == DialogResult.OK)
{
var imagem = new Bitmap(open.FileName);
var resizedImage = new Bitmap(imagem, pictureBox1.Size);
pictureBox1.Image = resizedImage;
}
}
你告訴我們:會發生什麼? –
PictureBox已經具有像這樣調整圖像大小的功能,將[BackgroundImageLayout](http://msdn.microsoft.com/en-gb/library/system.windows.forms.control.backgroundimagelayout.aspx)屬性設置爲[拉伸(http://msdn.microsoft。COM/EN-GB /庫/ system.windows.forms.imagelayout.aspx)。它會使圖像的大小與PictureBox相同 – musefan
爲什麼會投票?我已經說了會發生什麼......圖片在圖片框中顯示不完整...出現裁剪 – Ladessa