<PackageReference Include="System.Drawing.Common" Version="10.0.0-rc.1.25451.107" />

IPictureExtensions

static class IPictureExtensions
using System; using System.Drawing; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Win32.Foundation; using Windows.Win32.Graphics.GdiPlus; namespace Windows.Win32.System.Ole { internal static class IPictureExtensions { [NullableContext(1)] public static object CreateObjectFromImage(IPointer<GpImage> image) { ComScope<IPicture> scope = CreateFromImage(image); try { return Marshal.GetObjectForIUnknown((IntPtr)ref scope); } finally { scope.Dispose(); } } public unsafe static ComScope<IPicture> CreateFromImage([Nullable(1)] IPointer<GpImage> image) { PICTDESC pICTDESC = image.CreatePICTDESC(); ComScope<IPicture> scope = new ComScope<IPicture>(null); PInvokeCore.OleCreatePictureIndirect(&pICTDESC, IID.Get<IPicture>(), true, (void**)ref scope).ThrowOnFailure((IntPtr)0); return scope; } [NullableContext(1)] public static object CreateObjectFromIcon(IIcon icon, bool copy) { ComScope<IPicture> scope = CreateFromIcon(icon, copy); try { return Marshal.GetObjectForIUnknown((IntPtr)ref scope); } finally { scope.Dispose(); } } public unsafe static ComScope<IPicture> CreateFromIcon([Nullable(1)] IIcon icon, bool copy) { PICTDESC pICTDESC = icon.CreatePICTDESC(copy); ComScope<IPicture> scope = new ComScope<IPicture>(null); PInvokeCore.OleCreatePictureIndirect(&pICTDESC, IID.Get<IPicture>(), copy, (void**)ref scope).ThrowOnFailure((IntPtr)0); return scope; } } }