Click here to Skip to main content
15,920,005 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,

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

C#
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);
}



It may be because i haven't worked with "bitmap" before.

If possible please make it clear what those lines of code do.
Also, how can i learn about the "bitmap". Please suggest some articles or tutorials but not the MSDN. It's very difficult to learn from there.

Any kind of help would be appreciated
Posted
Comments
Sergey Alexandrovich Kryukov 7-Jan-15 21:29pm    
Software developers (including students) don't wine and don't complain, especially about so clear documentation as modern MSDN, especially on .NET. Such people rather get excited and try to find more difficult and interesting, non-trivial fields of application. Are you sure that you enjoy what you are doing and that you are learning profession which is right for your? :-)
—SA
BibhutiAlmighty 7-Jan-15 21:41pm    
Yes you are right. But i find the MSDN difficult because i don't think they provide a more detailed information. I just visited the site you referred. The sample which they have provided isn't commented.

for example:
The sample talks about working with pixels. then i search about the pixel and find another new keyword. this continues and i never find the exact answer that i'm searching for.
Sergey Alexandrovich Kryukov 7-Jan-15 21:43pm    
Keep trying, I see nothing wrong...
—SA
BibhutiAlmighty 7-Jan-15 22:11pm    
Thanks for your comment. I am trying

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
 
Share this answer
 
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."
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900