SHARE
TWEET

Untitled

a guest Mar 9th, 2011 221 Never
  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;
RAW Paste Data
Top