public static void UpdateBitmap(this Visual visual, Bitmap bitmap, VisualStyle style) { var gfx = Graphics.FromImage(bitmap); gfx.Clear(Color.Transparent); gfx.SmoothingMode = SmoothingMode.AntiAlias; gfx.TextRenderingHint = TextRenderingHint.AntiAlias; var ctx = new GraphicsContext(gfx, style); visual.Render(ctx, new VBox(bitmap.Size)); }
protected override void OnPaint(PaintEventArgs pe) { base.OnPaint(pe); if (_visual != null) { pe.Graphics.SmoothingMode = SmoothingMode.AntiAlias; var ctx = new GraphicsContext(pe.Graphics, VisualStyle.Default); _visual.Render(ctx, _size); } }
public static Bitmap ToBitmap(this Visual visual, Size size, PixelFormat pixelFormat, VisualStyle style) { var result = new Bitmap(size.Width, size.Height, pixelFormat); var gfx = Graphics.FromImage(result); gfx.SmoothingMode = SmoothingMode.AntiAlias; gfx.TextRenderingHint = TextRenderingHint.AntiAlias; var ctx = new GraphicsContext(gfx, style); visual.Render(ctx, new VBox(size)); return(result); }