C# 打印屏幕滚动控件
我有一个控件,它是可滚动的绘图仪。绘图仪完成绘图后,可以像这样滚动:
我的绘图仪是实时绘图仪,即它会随着时间的推移进行绘图,而不是静态绘图仪(您手动输入值的一个)。停止绘图仪后,我可以滚动绘图仪以查看结果。但是,我想将绘图仪保存到图像中,我正在尝试使用打印屏幕方法来完成此操作。但我能够捕获的只是绘图仪的可见部分,而不是绘图仪的不可见部分(这是因为它需要滚动)。我希望现在更清楚了。 打印屏幕的代码是:
// Set the bitmap object to the size of the screen
bmpScreenshot = new Bitmap(panel2.Bounds.Width, panel2.Bounds.Height, PixelFormat.Format32bppArgb);
// Create a graphics object from the bitmap
gfxScreenshot = Graphics.FromImage(bmpScreenshot);
Point p = this.PointToScreen(new Point(panel2.Bounds.X, panel2.Bounds.Y));
gfxScreenshot.CopyFromScreen(p.X, p.Y, 0, 0,
panel2.Bounds.Size, CopyPixelOperation.SourceCopy);
SaveFileDialog saveImageDialog = new SaveFileDialog();
saveImageDialog.Title = "Select output file:";
saveImageDialog.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif";
if (saveImageDialog.ShowDialog() == DialogResult.OK)
{
bmpScreenshot.Save(saveImageDialog.FileName, ImageFormat.Jpeg);
}
非常感谢。
i have a control that is the plotter which is scrollable. After the plotter has finished plotting, it is able to scroll just like this:
My plotter is a real-time plotter i.e. meaning it plots as time goes by and it's not a static plotter(one which u put in the values manually). After I've stopped the plotter, I'm able to scroll around the plotter to see the results. However, I want to save the plotter into an image, which I'm trying to do using print screen method. But what I was able to capture is only the visible part of the plotter, but not the non-visible part of the plotter(which is because it needs scrolling). I hope it's clearer now.
The code for the print screen is:
// Set the bitmap object to the size of the screen
bmpScreenshot = new Bitmap(panel2.Bounds.Width, panel2.Bounds.Height, PixelFormat.Format32bppArgb);
// Create a graphics object from the bitmap
gfxScreenshot = Graphics.FromImage(bmpScreenshot);
Point p = this.PointToScreen(new Point(panel2.Bounds.X, panel2.Bounds.Y));
gfxScreenshot.CopyFromScreen(p.X, p.Y, 0, 0,
panel2.Bounds.Size, CopyPixelOperation.SourceCopy);
SaveFileDialog saveImageDialog = new SaveFileDialog();
saveImageDialog.Title = "Select output file:";
saveImageDialog.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif";
if (saveImageDialog.ShowDialog() == DialogResult.OK)
{
bmpScreenshot.Save(saveImageDialog.FileName, ImageFormat.Jpeg);
}
Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看这里: http://www.eggheadcafe.com/community/aspnet/2/10201852/how-to-print-window-form-usig-cnet.aspx 您应该调用Win32 API PrintWindow。
Have a look here: http://www.eggheadcafe.com/community/aspnet/2/10201852/how-to-print-window-form-usig-cnet.aspx you should call the Win32 API PrintWindow.