I have a C# program where I am displaying a pictureBox of size
600x450. I have an image of a higher resolution that I am displaying
in this window. After I pan the image, I want to save only the visible
picture in the window. When I use pictureBox.Image.Save(...), it saves
the whole picture, not just the visual portion? How can I do this?
Try to use this.
using (Bitmap bitmap = new Bitmap(YourPictureBox.ClientSize.Width,
YourPictureBox.ClientSize.Height))
{
YourPictureBox.DrawToBitmap(bitmap, YourPictureBox.ClientRectangle);
bitmap.Save(yourfilename, ImageFormat.Png);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With