public static Image getImage(ParseTreeNode raiz) { String grafoDOT = ControlDOT.getDOT(raiz); WINGRAPHVIZLib.DOT dot = new WINGRAPHVIZLib.DOT(); WINGRAPHVIZLib.BinaryImage img = dot.ToPNG(grafoDOT); byte[] imageBytes = Convert.FromBase64String(img.ToBase64String()); MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length); Image imagen = Image.FromStream(ms, true); return(imagen); }
private static Image GenerateDotGraphImage(string dotCode) { // Generate dot graph WINGRAPHVIZLib.DOTClass dot = new WINGRAPHVIZLib.DOTClass(); WINGRAPHVIZLib.BinaryImage img = dot.ToPNG(dotCode); // Convert Base64 String to byte[] byte[] imageBytes = Convert.FromBase64String(img.ToBase64String()); MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length); // Convert byte[] to Stream ms.Write(imageBytes, 0, imageBytes.Length); // Convert Stream to Image Image image = Image.FromStream(ms, true); return(image); }
private static Image generarImagen(String grafico) { // String graph = DOT(); WINGRAPHVIZLib.DOT dot = new WINGRAPHVIZLib.DOT(); WINGRAPHVIZLib.BinaryImage img = dot.ToJPEG(grafico); byte[] imageBytes = Convert.FromBase64String(img.ToBase64String()); MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length); ms.Write(imageBytes, 0, imageBytes.Length); Image image = Image.FromStream(ms, true); img.Save(@"C:\\Users\PC\\Desktop\\thompson.jpg"); return(image); }