public static ComObject <T> CreateBitmap <T>(this ID2D1DeviceContext device, D2D_SIZE_U size, IntPtr srcData, uint pitch, D2D1_BITMAP_PROPERTIES1 properties) where T : ID2D1Bitmap { if (device == null) { throw new ArgumentNullException(nameof(device)); } device.CreateBitmap(size, srcData, pitch, ref properties, out var bmp).ThrowOnError(); return(new ComObject <T>((T)bmp)); }
public static void CreateDeviceContextCPUBitmap( ID2D1DeviceContext target, int width, int height) { BitmapProperties1 props = new() { BitmapOptions = BitmapOptions.Target | BitmapOptions.GdiCompatible, PixelFormat = new Vortice.DCommon.PixelFormat(Format.B8G8R8A8_UNorm, Vortice.DCommon.AlphaMode.Premultiplied) }; using (ID2D1Bitmap1 bitmap = target.CreateBitmap(new Size(width, height), IntPtr.Zero, 0, ref props)) { target.Target = bitmap; } } }