Ejemplo n.º 1
0
        /// <summary>
        /// Render the given GraphViz code into an image.
        /// </summary>
        /// <param name="dotSourceText"></param>
        /// <param name="returnType"></param>
        /// <returns></returns>
        public Image RenderToImage(string dotSourceText, GvImageOutputFormat returnType)
        {
            var byteArray = RenderGraph(dotSourceText, returnType);

            return(byteArray.Length == 0
                ? null
                : GetImageFromByteArray(byteArray));

            //using (var stream = new MemoryStream(bytesArray))
            //{
            //    return Image.FromStream(stream);
            //}
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Render the given GraphViz code into an image and also save it to file.
        /// </summary>
        /// <param name="dotSourceText"></param>
        /// <param name="returnType"></param>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public Image RenderToImageAndFile(string dotSourceText, GvImageOutputFormat returnType, string filePath)
        {
            var byteArray = RenderGraph(dotSourceText, returnType);

            if (byteArray.Length == 0)
            {
                return(null);
            }

            try
            {
                File.WriteAllBytes(filePath, byteArray);
            }
            catch (Exception e)
            {
                _errorsList.Add(e.Message);
            }

            return(GetImageFromByteArray(byteArray));
        }