Exemple #1
0
        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));
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
        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);
        }