Guest User

Untitled

a guest
Sep 22nd, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.91 KB | None | 0 0
  1. private Bitmap PrintScreen()
  2.     {
  3.       Rectangle virtualScreen = SystemInformation.VirtualScreen;
  4.       Bitmap bitmap = new Bitmap(virtualScreen.Width, virtualScreen.Height);
  5.       Graphics graphics = Graphics.FromImage((Image) bitmap);
  6.       IntPtr hdc = graphics.GetHdc();
  7.       int dwRop = 13369376;
  8.       SpySource.BitBlt(hdc, 0, 0, virtualScreen.Width, virtualScreen.Height, SpySource.GetDC(IntPtr.Zero), 0, 0, dwRop);
  9.       graphics.ReleaseHdc(hdc);
  10.       graphics.Dispose();
  11.       return bitmap;
  12.     }
  13.  
  14.     private Bitmap PrintScreen(int width, int height)
  15.     {
  16.       Rectangle virtualScreen = SystemInformation.VirtualScreen;
  17.       Bitmap bitmap1 = new Bitmap(virtualScreen.Width, virtualScreen.Height);
  18.       Graphics graphics1 = Graphics.FromImage((Image) bitmap1);
  19.       IntPtr hdc = graphics1.GetHdc();
  20.       int dwRop = 13369376;
  21.       SpySource.BitBlt(hdc, 0, 0, virtualScreen.Width, virtualScreen.Height, SpySource.GetDC(IntPtr.Zero), 0, 0, dwRop);
  22.       graphics1.ReleaseHdc(hdc);
  23.       graphics1.Dispose();
  24.       if (virtualScreen.Width == width && virtualScreen.Height == height)
  25.         return bitmap1;
  26.       Bitmap bitmap2 = new Bitmap(width, height);
  27.       Graphics graphics2 = Graphics.FromImage((Image) bitmap2);
  28.       graphics2.DrawImage((Image) bitmap1, 0, 0, width, height);
  29.       bitmap1.Dispose();
  30.       graphics2.Dispose();
  31.       return bitmap2;
  32.     }
  33.  
  34.     private Bitmap PrintScreen2(int width, int height)
  35.     {
  36.       Rectangle virtualScreen = SystemInformation.VirtualScreen;
  37.       Bitmap bitmap = new Bitmap(width, height);
  38.       Graphics graphics = Graphics.FromImage((Image) bitmap);
  39.       IntPtr hdc = graphics.GetHdc();
  40.       int dwRop = 13369376;
  41.       SpySource.StretchBlt(hdc, 0, 0, width, height, SpySource.GetDC(IntPtr.Zero), 0, 0, virtualScreen.Width, virtualScreen.Height, dwRop);
  42.       graphics.ReleaseHdc(hdc);
  43.       graphics.Dispose();
  44.       return bitmap;
  45.     }
Advertisement
Add Comment
Please, Sign In to add comment