Don’t forget to clean up after using Image img = Image.FromHbitmap(hBitmap) or you will experience serious memory leaks.
Image img = null; try { img = Image.FromHbitmap(hBitmap); }finally{ DeleteObject(hBitmap); img.Dispose(); } [DllImport("gdi32.dll", EntryPoint = "DeleteObject")] public static extern IntPtr DeleteObject(IntPtr hDc);