<PackageReference Include="System.Drawing.Common" Version="11.0.0-preview.2.26159.112" />

Windows.Win32.Graphics.Gdi.CreateBitmapScope

Helper to scope lifetime of a HBITMAP created via CreateBitmap Deletes the HBITMAP (if any) when disposed.
namespace Windows.Win32.Graphics.Gdi { internal readonly ref struct CreateBitmapScope { public HBITMAP HBITMAP { get; } public bool IsNull { get; } public unsafe CreateBitmapScope(int nWidth, int nHeight, uint nPlanes, uint nBitCount, void* lpvBits); public CreateBitmapScope(HDC hdc, int cx, int cy); public static implicit operator HBITMAP(ref CreateBitmapScope scope); public static implicit operator HGDIOBJ(ref CreateBitmapScope scope); public static explicit operator IntPtr(ref CreateBitmapScope scope); public void Dispose(); } }