Manipulate Printscreen in C#

Asked

Viewed 497 times

0

A while ago a guy here at the forum helped me to put together a program to take a photo of a specific window that had opened on the computer. I wonder if I can get this picture instead of the whole window, be just a part of the window!

Question link: Printscreen in C#

1 answer

1


You will need 2 libraries:

using System.Drawing;  
using System.Drawing.Imaging; 

And to take the screenshot:

private void PrintScreen()
{  
    Bitmap printscreen = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
    Graphics graphics = Graphics.FromImage(printscreen as Image);
    graphics.CopyFromScreen(0, 0, 0, 0, printscreen.Size); //Copia a imagem da tela
    printscreen.Save(@"C:\Temp\printscreen.jpg", ImageFormat.Jpeg); //Salva a captura de tela
}

Documentations: System.Drawing.Imaging and System Drawing..

  • Copyfromscreen(0, 0, 0, 0, printscreen.Size); ?

  • 1

    Yes, but if you are going to change, I recommend using pointers. Take a look therein.

  • Thank you very much, man, you helped a lot!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.