/// <summary>Initializes a new instance of the <see cref="BufferedPainter"/> class and begins a buffered paint operation.</summary> /// <param name="hdc">The handle of the target DC on which the buffer will be painted.</param> /// <param name="targetRectangle">Specifies the area of the target DC in which to paint.</param> /// <param name="paintParams">The paint operation parameters. This value can be <see langword="null"/>.</param> /// <param name="fmt">The format of the buffer.</param> /// <exception cref="Win32Exception">Buffered painting could not initialize.</exception> public BufferedPainter(HDC hdc, Rectangle targetRectangle, BP_PAINTPARAMS paintParams = null, BP_BUFFERFORMAT fmt = BP_BUFFERFORMAT.BPBF_TOPDOWNDIB) { RECT target = targetRectangle; hbp = BeginBufferedPaint(hdc, target, fmt, paintParams, out var phdc); if (hbp.IsInvalid) { throw new Win32Exception(); } if (!phdc.IsNull) { Graphics = Graphics.FromHdc((IntPtr)phdc); } }
/// <summary>Initializes a new instance of the <see cref="BufferedPainter"/> class and begins a buffered paint operation.</summary> /// <param name="hdc">The handle of the target DC on which the buffer will be painted.</param> /// <param name="targetRectangle">Specifies the area of the target DC in which to paint.</param> /// <param name="paintParams">The paint operation parameters. This value can be <see langword="null"/>.</param> /// <param name="fmt">The format of the buffer.</param> /// <exception cref="Win32Exception">Buffered painting could not initialize.</exception> public BufferedPainter(SafeDCHandle hdc, Rectangle targetRectangle, BP_PAINTPARAMS paintParams = null, BP_BUFFERFORMAT fmt = BP_BUFFERFORMAT.BPBF_TOPDOWNDIB) { RECT target = targetRectangle; hbp = BeginBufferedPaint(hdc, ref target, fmt, paintParams, out IntPtr phdc); if (hbp.IsInvalid) { throw new Win32Exception(); } if (phdc != IntPtr.Zero) { Graphics = Graphics.FromHdc(phdc); } }
public static extern HRESULT GetBufferedPaintTargetRect(SafeBufferedPaintHandle hBufferedPaint, out RECT prc);
public static extern IntPtr GetBufferedPaintTargetDC(SafeBufferedPaintHandle hBufferedPaint);
public static extern HRESULT GetBufferedPaintBits(SafeBufferedPaintHandle hBufferedPaint, out IntPtr ppbBuffer, out int pcxRow);
public static extern HRESULT BufferedPaintSetAlpha(SafeBufferedPaintHandle hBufferedPaint, ref RECT prc, byte alpha);
public static extern HRESULT BufferedPaintClear(SafeBufferedPaintHandle hBufferedPaint, ref RECT prc);