【问题标题】:After panning an image in a picture box, how to save only the visible image在图片框中平移图像后,如何只保存可见图像
【发布时间】:2015-09-18 12:47:24
【问题描述】:

我有一个 C# 程序,我在其中显示一个大小的图片框 600x450。我有一张我正在显示的更高分辨率的图像 在这个窗口中。平移图像后,我只想保存可见的 窗口中的图片。当我使用pictureBox.Image.Save(...) 时,它可以节省 整个画面,而不仅仅是视觉部分?我该怎么做?

【问题讨论】:

标签: c# image graphics picturebox


【解决方案1】:

尝试使用它。

using (Bitmap bitmap = new Bitmap(YourPictureBox.ClientSize.Width,
                               YourPictureBox.ClientSize.Height))
{
   YourPictureBox.DrawToBitmap(bitmap, YourPictureBox.ClientRectangle);
   bitmap.Save(yourfilename, ImageFormat.Png);
}

【讨论】:

  • 作为后续,如果我平移图片框中的图像然后使用上面的代码,它会保存整个图像。如果我不平移而只放大,它可以工作。泰。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-06-15
  • 1970-01-01
  • 2013-10-05
  • 1970-01-01
  • 2022-08-22
  • 2014-04-26
  • 2016-10-31
相关资源
最近更新 更多