Exemplo n.º 1
0
        private void ExportImage(string path)
        {
            var code = _generator.GenerateCode(ExportStrokeWidth);
            var svg  = SvgDocument.FromSvg <SvgDocument>(code);

            using (var bm = SvgRasterizer.Rasterize(svg, ExportGridStrokeWidth, ExportGridSize))
                using (var f = File.OpenWrite(path))
                {
                    bm.Save(f, SelectImageFormat(path));
                }
        }
Exemplo n.º 2
0
        private void RenderSvg()
        {
            float wFactor = pictureBox.Width / _svg.Width;
            float hFactor = pictureBox.Height / _svg.Height;

            if (pictureBox.Width == 0 || pictureBox.Height == 0)
            {
                return;
            }

            float factor = Math.Min(wFactor, hFactor);

            int w = (int)(_svg.Width * factor), h = (int)(_svg.Height * factor);

            var pp = pictureBox.Image;

            pictureBox.Image = _svgRasterizer.Rasterize(_svg, new Point(w, h));
            pp?.Dispose();
        }