private void ButtonLoad_onClick(object sender, EventArgs e)//load button
        {
            //Todo: Add ability to load image file formats also
            //OpenFileDialogue.Filter = "SVG Files (*.svg)|*.svg|Image files (*.png, *.tiff, *.tif)|*.png;.tiff;.tif|All files (*.*)|*.*";
            //This may be a significant undertaking
            //Most of these routines are built with an SVG being assumed.

            OpenFileDialogue.Filter = "SVG Files (*.svg)|*.svg|All files (*.*)|*.*";
            if (OpenFileDialogue.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            lastSourceFilename = OpenFileDialogue.FileName;


            //to minimize disk IO this is only opened once here and when it needs to be rerendered for actual field generation.
            SvgDocument d = SvgDocument.Open(OpenFileDialogue.FileName);

            lastWidthHeight             = new Tuple <float, float>(d.Width.Value, d.Height.Value);
            DecalLoaded                 = true;
            this.GenerateButton.Enabled = true;
            SourceAspect                = lastWidthHeight.Item1 / lastWidthHeight.Item2;
            int sourceHeight = 4096;
            int sourceWidth  = (int)(4096 * (1.0f / SourceAspect));

            //rendered once to memory. That file in memory is downsampled for the preview image as the window is resized.
            SourceBitmap       = SignedDistanceFieldRenderer.RenderSvgToBitmapWithMaximumSize(lastSourceFilename, sourceWidth, sourceHeight);
            decalPreview.Image = BitmapHelper.ResizeBitmapToFit(SourceBitmap, decalPreview.Width, decalPreview.Height, SourceAspect);
        }
        private void button3_Click(object sender, EventArgs e)
        {
            svgOpenFile.Filter = "SVG Files (*.svg)|*.svg|All files (*.*)|*.*";
            if (svgOpenFile.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            lastSvgFilename    = svgOpenFile.FileName;
            decalPreview.Image = SignedDistanceFieldRenderer.RenderSvgToBitmapWithMaximumSize(
                svgOpenFile.FileName, decalPreview.Width, decalPreview.Height);
        }
        //TODO: put this in the renderer class where it fits better. Will need to convert lastWidthHeight to a variable passed in.
        private Bitmap RenderSVGToFit(string FileName, int width, int height)
        {
            float documentAspect = lastWidthHeight.Item1 / lastWidthHeight.Item2;
            int   renderheight, renderwidth;

            if ((documentAspect <= 1.0f))
            {
                renderheight = height;
                renderwidth  = (int)(height * documentAspect);
            }
            else
            {
                renderheight = (int)(width * (1.0f / documentAspect));
                renderwidth  = width;
            }

            return(SignedDistanceFieldRenderer.RenderSvgToBitmapWithMaximumSize(FileName, renderwidth, renderheight));
        }