捕获屏幕截图并在图片框中显示 [英] Capturing screenshot and showing it in picturebox

查看:73
本文介绍了捕获屏幕截图并在图片框中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



这是我在StackOverflow中得到的答案,但我不明白。



Hello,

This is the answer i got in StackOverflow but i didn't understand it.

Rectangle bounds = Screen.GetBounds(Point.Empty);
using(Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
{
    using(Graphics g = Graphics.FromImage(bitmap))
    {
         g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
    }
    bitmap.Save("test.jpg", ImageFormat.Jpeg);
}







可能是因为我之前没有使用位图 。



如果可能,请说清楚这些代码行。

另外,我如何了解位图。请建议一些文章或教程,但不是MSDN。从那里学习是非常困难的。



任何形式的帮助将不胜感激

推荐答案

不是很明显你怎么能了解位图?请参阅: http://msdn.microsoft.com /en-us/library/system.drawing.bitmap%28v=vs.110%29.aspx [ ^ ]。



同样,请参阅您显示的代码示例中每种类型的MSDN文档。然而,这不是一种有效的学习方式。您应该从概念概述开始阅读文档,并编写自己的代码。不要浪费你的时间阅读你不理解的代码。来自对方的理解。



-SA
Isn't that obvious how can you "learn about bitmap"? Please see: http://msdn.microsoft.com/en-us/library/system.drawing.bitmap%28v=vs.110%29.aspx[^].

Likewise, see the MSDN documentation of each type from the code sample you show. However, this is not a productive way of learning things. You should better read documentation, starting from conceptual overviews, and write your own code. Don't waste your time of reading code you don't understand. Come to understanding from the opposite side.

—SA


是的,你可以学习一个从你不理解的工作代码开始很多......首先。



但是,要学习你必须研究代码做什么 ;并且,你这样做:



1.创建使用您下载或复制的代码的测试代码;验证您正在学习的代码是否符合预期:给出预期结果。



2.在您学习的代码的第一行放置一个断点,运行测试示例,当您点击断点时,使用Visual Studio的运行时检查弹出变量值:检查这些值的含义/暗示/表示。



3.单步(F11)通过代码检查每个步骤的副作用,或创建的任何新对象及其状态,与步骤#2中的方法相同。



这是使代码成为你自己的代码:了解其功能的一种可能模式。



第二种模式,同样重要的是,使用文档来查找你不清楚的类型,属性,对象方法等的定义,并研究它。



如果你陷入困境,那么在MSDN,CodeProject上寻找教程文章。



如果你被困在细节中,把你的学习转到大局。
Yes, you can learn a lot from working code you don't understand ... at first.

But, to learn you have to study what the code does; and, you do that by:

1. create test code that uses the code you downloaded, or copied; verify code you are studying does what it is supposed to: gives an expected result.

2. put a break-point on the first line of the code you study, run the test example, and, when you hit the break-point, examine, using Visual Studio's run-time inspection pop-ups the value of variables: think about what those values mean/imply/signify.

3. single-step (F11) through the code examining each step's side-effects, or any new objects created and their state, in the same way you did in step #2.

That's one possible mode of "making the code your own:" understanding its functions.

The second mode, equally important, is to use the documentation to look-up the definition of Types, Properties, Object methods, etc. you are not clear about, and study that.

If you get "stuck," then look for tutorial articles on MSDN, CodeProject.

If you are stuck in the details, switch your study to the "big picture."


这篇关于捕获屏幕截图并在图片框中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆