Guest User

Untitled

a guest
May 25th, 2016
2,728
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1.  
  2.         internal static byte[] TakeDesktopScreenshot()
  3.         {
  4.             try
  5.             {
  6.                 using (Bitmap b = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb))
  7.                 {
  8.                     using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(b))
  9.                     {
  10.                         g.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
  11.                         MemoryStream str = new MemoryStream();
  12.                         b.Save(str, ImageFormat.Jpeg);
  13.  
  14.                         return str.ToArray();
  15.                     }
  16.                 }
  17.             }
  18.             catch
  19.             {
  20.             }
Advertisement
Add Comment
Please, Sign In to add comment