示例#1
0
 /// <summary>Creates a <see cref="Bitmap"/> from a <see cref="SafeHBITMAP"/>.</summary>
 /// <param name="hbmp">The HBMP value.</param>
 /// <returns>The Bitmap instance.</returns>
 public static Bitmap ToBitmap(this SafeHBITMAP hbmp) => ((HBITMAP)hbmp).ToBitmap();
示例#2
0
 /// <summary>Creates a <see cref="BitmapSource"/> from an <see cref="SafeHBITMAP"/> preserving transparency, if possible.</summary>
 /// <param name="hbmp">The SafeHBITMAP value.</param>
 /// <returns>The BitmapSource instance. If <paramref name="hbmp"/> is a <c>NULL</c> handle, <see langword="null"/> is returned.</returns>
 public static BitmapSource ToBitmapSource(this SafeHBITMAP hbmp) => hbmp is null || hbmp.IsInvalid ? null : CreateBitmapSourceFromHBitmap(hbmp.DangerousGetHandle(), default, default, BitmapSizeOptions.FromEmptyOptions());