Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 9th, 2011  |  syntax: C#  |  size: 0.97 KB  |  views: 186  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Bitmap bmp = null;
  2.             SIZE size;
  3.  
  4.             size.cx = Screen.PrimaryScreen.Bounds.Width;
  5.             size.cy = Screen.PrimaryScreen.Bounds.Height;
  6.  
  7.             IntPtr Src = PlatformInvokeUSER32.GetDC(IntPtr.Zero);
  8.             IntPtr Dest = PlatformInvokeGDI32.CreateCompatibleDC(Src);
  9.             IntPtr HBitmap = (IntPtr)null;
  10.             IntPtr hOld = IntPtr.Zero;
  11.  
  12.             HBitmap = PlatformInvokeGDI32.CreateCompatibleBitmap(Src, size.cx, size.cy);
  13.  
  14.             hOld = (IntPtr)PlatformInvokeGDI32.SelectObject(Dest, HBitmap);
  15.  
  16.             PlatformInvokeGDI32.BitBlt(Dest, 0, 0, size.cx, size.cy, Src, 0, 0, PlatformInvokeGDI32.SRCCOPY);
  17.             PlatformInvokeGDI32.SelectObject(Dest, hOld);
  18.             PlatformInvokeGDI32.DeleteDC(Dest);
  19.             PlatformInvokeUSER32.ReleaseDC(IntPtr.Zero, Src);
  20.  
  21.             bmp = System.Drawing.Image.FromHbitmap(HBitmap);
  22.  
  23.             PlatformInvokeGDI32.DeleteObject(HBitmap);
  24.  
  25.             return bmp;