internal InteropBitmap(IntPtr hbitmap, IntPtr hpalette, Int32Rect sourceRect, BitmapSizeOptions sizeOptions, WICBitmapAlphaChannelOption alphaOptions) : base(true) // Use virtuals { _bitmapInit.BeginInit(); using (FactoryMaker myFactory = new FactoryMaker()) { HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateBitmapFromHBITMAP( myFactory.ImagingFactoryPtr, hbitmap, hpalette, alphaOptions, out _unmanagedSource)); Debug.Assert (_unmanagedSource != null && !_unmanagedSource.IsInvalid); } _unmanagedSource.CalculateSize(); _sizeOptions = sizeOptions; _sourceRect = sourceRect; _syncObject = _unmanagedSource; _bitmapInit.EndInit(); FinalizeCreation(); }
unsafe internal static BitmapSource CriticalCreateBitmapSourceFromHBitmap( IntPtr bitmap, IntPtr palette, Int32Rect sourceRect, BitmapSizeOptions sizeOptions, WICBitmapAlphaChannelOption alphaOptions) { if (bitmap == IntPtr.Zero) { throw new ArgumentNullException("bitmap"); } return(new InteropBitmap(bitmap, palette, sourceRect, sizeOptions, alphaOptions)); // use the critical version }
unsafe internal static BitmapSource CriticalCreateBitmapSourceFromHBitmap( IntPtr bitmap, IntPtr palette, Int32Rect sourceRect, BitmapSizeOptions sizeOptions, WICBitmapAlphaChannelOption alphaOptions) { if (bitmap == IntPtr.Zero) { throw new ArgumentNullException("bitmap"); } return new InteropBitmap(bitmap, palette, sourceRect, sizeOptions, alphaOptions); // use the critical version }
public virtual int CreateBitmapFromHBITMAP( out HBITMAP__ hBitmap, out HPALETTE__ hPalette, WICBitmapAlphaChannelOption options, out IWICBitmap ppIBitmap ) { var fp = GetFunctionPointer(21); if (m_CreateBitmapFromHBITMAPFunc == null) { m_CreateBitmapFromHBITMAPFunc = (CreateBitmapFromHBITMAPFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(CreateBitmapFromHBITMAPFunc)); } ppIBitmap = new IWICBitmap(); return(m_CreateBitmapFromHBITMAPFunc(m_ptr, out hBitmap, out hPalette, options, out ppIBitmap.PtrForNew)); }
/// <summary> /// Construct a BitmapSource from an HBITMAP. /// </summary> /// <param name="hbitmap"></param> /// <param name="hpalette"></param> /// <param name="sourceRect"></param> /// <param name="sizeOptions"></param> /// <param name="alphaOptions"></param> internal InteropBitmap(IntPtr hbitmap, IntPtr hpalette, Int32Rect sourceRect, BitmapSizeOptions sizeOptions, WICBitmapAlphaChannelOption alphaOptions) : base(true) // Use virtuals { _bitmapInit.BeginInit(); using (FactoryMaker myFactory = new FactoryMaker()) { HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateBitmapFromHBITMAP( myFactory.ImagingFactoryPtr, hbitmap, hpalette, alphaOptions, out _unmanagedSource)); Debug.Assert(_unmanagedSource != null && !_unmanagedSource.IsInvalid); } _unmanagedSource.CalculateSize(); _sizeOptions = sizeOptions; _sourceRect = sourceRect; _syncObject = _unmanagedSource; _bitmapInit.EndInit(); FinalizeCreation(); }
public int CreateBitmapFromHBITMAP([NativeTypeName("HBITMAP")] IntPtr hBitmap, [NativeTypeName("HPALETTE")] IntPtr hPalette, WICBitmapAlphaChannelOption options, [NativeTypeName("IWICBitmap **")] IWICBitmap **ppIBitmap) { return(((delegate * unmanaged[Stdcall] < IWICImagingFactory2 *, IntPtr, IntPtr, WICBitmapAlphaChannelOption, IWICBitmap **, int >)(lpVtbl[21]))((IWICImagingFactory2 *)Unsafe.AsPointer(ref this), hBitmap, hPalette, options, ppIBitmap)); }
public HRESULT CreateBitmapFromHBITMAP(HBITMAP hBitmap, HPALETTE hPalette, WICBitmapAlphaChannelOption options, IWICBitmap **ppIBitmap) { return(((delegate * unmanaged <IWICComponentFactory *, HBITMAP, HPALETTE, WICBitmapAlphaChannelOption, IWICBitmap **, int>)(lpVtbl[21]))((IWICComponentFactory *)Unsafe.AsPointer(ref this), hBitmap, hPalette, options, ppIBitmap)); }
internal static extern int /*HRESULT*/ CreateBitmapFromHBITMAP( IntPtr THIS_PTR, IntPtr hBitmap, IntPtr hPalette, WICBitmapAlphaChannelOption options, out BitmapSourceSafeMILHandle /* IWICBitmap */ ppIBitmap);
public static WicBitmapSource FromHBitmap(IntPtr bitmapHandle, IntPtr paletteHandle, WICBitmapAlphaChannelOption options = WICBitmapAlphaChannelOption.WICBitmapUseAlpha) => new WicBitmapSource(WICImagingFactory.CreateBitmapFromHBITMAP(bitmapHandle, paletteHandle, options));
public extern IWICBitmap CreateBitmapFromHBITMAP([In] IntPtr hBitmap, [In] IntPtr hPalette, [In] WICBitmapAlphaChannelOption options);
public static IComObject <IWICBitmap> CreateBitmapFromHBITMAP(this IWICImagingFactory factory, IntPtr bitmapHandle, IntPtr paletteHandle, WICBitmapAlphaChannelOption options = WICBitmapAlphaChannelOption.WICBitmapUseAlpha) { if (factory == null) { throw new ArgumentNullException(nameof(factory)); } factory.CreateBitmapFromHBITMAP(bitmapHandle, paletteHandle, options, out var value).ThrowOnError(); return(new ComObject <IWICBitmap>(value)); }
public static IComObject <IWICBitmap> CreateBitmapFromHBITMAP(this IComObject <IWICImagingFactory> factory, IntPtr bitmapHandle, IntPtr paletteHandle, WICBitmapAlphaChannelOption options = WICBitmapAlphaChannelOption.WICBitmapUseAlpha) => CreateBitmapFromHBITMAP(factory?.Object, bitmapHandle, paletteHandle, options);
public static IComObject <IWICBitmap> CreateBitmapFromHBITMAP(IntPtr bitmapHandle, IntPtr paletteHandle, WICBitmapAlphaChannelOption options = WICBitmapAlphaChannelOption.WICBitmapUseAlpha) => WithFactory(f => f.CreateBitmapFromHBITMAP(bitmapHandle, paletteHandle, options));