How do I resize an image in a picture box. But only in the picture box, so that when I go to save the image it's still full size. here's an example of my code.
// If the user has chosen a path where to save the screenshot if (saveScreenshot.ShowDialog() == DialogResult.OK){
// Hide the form so that it does not appear in the screenshot this.Hide(); // Set the bitmap object to the size of the screenbmpScreenshot =
new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb); // Create a graphics object from the bitmapgfxScreenshot =
Graphics.FromImage(bmpScreenshot); // Take the screenshot from the upper left corner to the right bottom cornergfxScreenshot.CopyFromScreen(
Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy); this.imageDisplay.Image = bmpScreenshot; // Save the screenshot to the specified path that the user has chosenbmpScreenshot.Save(saveScreenshot.FileName,
ImageFormat.Jpeg); // Show the form again this.Show();}
Joe SmithPosted Oct 27, 2007, 10:46 AM
No that was right, thanks alot. Just that didn't work so I found another way.
Ryan TurneyPosted Oct 15, 2007, 9:51 PM
If I understand you correctly, you want to be able to take an image and place it into the picturebox. Then have it fit that picturebox and be able to save without a changed ratio, correct? If so, you can try and set the picturebox to stretch the image. It will just take an image and "force fit" it into the picturebox and it shouldn't save the image's ratio after the application is finished.
pictureBox1.SizeMode = System.Windows.Forms.
PictureBoxSizeMode.StretchImage;I'm sorry if this is not what you are looking for, I'm a little confused on your question.