Scale Image to fit PictureBox control width and height C#
By Mash B
Scale the image to fit the Picturebox control widht and height
// Load local image to PictureBox control
pictureBox1.Load(filePath);
//create a new Bitmap with the proper dimensions
Bitmap finalImg = new Bitmap(pictureBox1.Image, pictureBox1.Width,pictureBox1.Height);
//center the new image
pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
//set the new image
pictureBox1.Image = finalImg;
pictureBox1.Show();
Scale Image to fit PictureBox control width and height C# (4489 Views)