1

Topic: Image. FromHbitmap (IntPtr hbitmap)

Help please.


There is all a familiar method:



public static Bitmap System. Drawing. Image. FromHbitmap (IntPtr hbitmap) 



Where hbitmap it is a descriptor of bitmap GDI.


Question in the following: what is this descriptor (the structure on which it can eat what  specifies)?


The question has been caused by that that if to use  function for WPF:




        private static System.Windows.Media.Imaging.BitmapSource loadBitmap (System. Drawing. Bitmap source) 
        { 
            IntPtr ip = source. GetHbitmap (); 
            System.Windows.Media.Imaging.BitmapSource bs = null; 
            try 
            { 
                bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap (ip, 
                   IntPtr. Zero, System. Windows. Int32Rect. Empty, 
                   System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions ()); 
            }
            finally 
            { 
                GDI32.DeleteDC (ip); 
            }

            return bs; 
        }



And to try to display a desktop screenshot icons and buttons are displayed only: to close, tear and contract, and all remaining - a white background. In case of Image. FromHbitmap (IntPtr hbitmap) all is displayed correctly.