packages/Windows API Code Pack 1.1/source/Samples/Shell/StarBackupUsingLibraries/CS/StarBackupHelper.cs
/// <summary>
/// Convert GDI bitmap into a WPF BitmapSource
/// </summary>
/// <param name="source"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <returns></returns>
Convert GDI bitmap into a WPF BitmapSource
Convert GDI bitmap into a WPF BitmapSource
public static BitmapSource ConvertGDI_To_WPF(System.Drawing.Bitmap bmp)
        {
            BitmapSource bms = null;
            if (bmp != null)
            {
                IntPtr h_bm = bmp.GetHbitmap();
                bms = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(h_bm, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
            }
            return bms;
        }
public static BitmapSource ConvertGDI_To_WPF ( System . Drawing . Bitmap bmp ) { BitmapSource bms = null ; if ( bmp != null ) { IntPtr h_bm = bmp . GetHbitmap ( ) ; bms = System . Windows . Interop . Imaging . CreateBitmapSourceFromHBitmap ( h_bm , IntPtr . Zero , Int32Rect . Empty , BitmapSizeOptions . FromEmptyOptions ( ) ) ; } return bms ; }
Convert GDI bitmap into a WPF BitmapSource
Convert GDI bitmap into a WPF BitmapSource
None
bmp
System.Drawing.Bitmap
source
None
width
None
height
None