/// <include file='doc\Image.uex' path='docs/doc[@for="Image.FromHbitmap1"]/*' /> /// <devdoc> /// <para> /// Creates a <see cref='System.Drawing.Bitmap'/> from the specified Windows /// handle with the specified color palette. /// </para> /// </devdoc> public static Bitmap FromHbitmap(IntPtr hbitmap, IntPtr hpalette) { IntSecurity.ObjectFromWin32Handle.Demand(); IntPtr bitmap = IntPtr.Zero; int status = SafeNativeMethods.GdipCreateBitmapFromHBITMAP(new HandleRef(null, hbitmap), new HandleRef(null, hpalette), out bitmap); if (status != SafeNativeMethods.Ok) { throw SafeNativeMethods.StatusException(status); } return(Bitmap.FromGDIplus(bitmap)); }