/// <summary> /// Obtiene la informacion de una imagen en formato base64 /// </summary> /// <returns></returns> public string GetAsImage64() { String sdot = GetASDOT(); DOT dot = new DOT(); BinaryImage img = dot.ToPNG(sdot); img.Save(Path.Combine(folder, fname)); return(img.ToBase64String()); }
public static void generarOtraImagen(ParseTreeNode raiz) { try { String grafo_en_DOT = ControlDOT.ControlDOT.getDOT2(raiz); DOT dot = new DOT(); BinaryImage img = dot.ToPNG(grafo_en_DOT); img.Save("C:/Users/pablo/Desktop/Compi Junio/[Compi1]Practica1/[Compi1]Practica1/imagenes/ASA.png"); MessageBox.Show("Se creó el ASA."); } catch (Exception) { MessageBox.Show("No se creó el ASA."); } }
public static void generarImagenEXP(ParseTreeNode raiz, int numero) { try { String grafo_en_DOT = Programa.DibujarEXP(raiz); DOT dot = new DOT(); BinaryImage img = dot.ToPNG(grafo_en_DOT); img.Save("C:/Users/pablo/Desktop/CompiJunio/[Compi1]Proyecto2/[Compi1]Proyecto2/imagenes/EXP" + numero + ".png"); MessageBox.Show("Se creó el EXP" + numero + "."); Programa.sw.WriteLine("<tr>"); Programa.sw.WriteLine("<th>DibujarEXP: AST de una expresion en particular</th>"); Programa.sw.WriteLine("<th>EXP_" + numero + "</th>"); Programa.sw.WriteLine("<th><img src=" + "\"" + "[Compi1]Proyecto2/imagenes/EXP" + numero + ".png" + "\"" + "></th>"); Programa.sw.WriteLine("</tr>"); } catch (Exception) { MessageBox.Show("No se creó el EXP" + numero + "."); } }
public static void generarImagenAST(ParseTreeNode raiz, String nombre) { try { String grafo_en_DOT = Programa.DibujarAST(raiz); DOT dot = new DOT(); BinaryImage img = dot.ToPNG(grafo_en_DOT); img.Save("C:/Users/pablo/Desktop/CompiJunio/[Compi1]Proyecto2/[Compi1]Proyecto2/imagenes/AST" + nombre + ".png"); MessageBox.Show("Se creó el AST del " + nombre + "."); Programa.sw.WriteLine("<tr>"); Programa.sw.WriteLine("<th>DibujarAST: AST de una funcion en particular</th>"); Programa.sw.WriteLine("<th>AST_" + nombre + "</th>"); Programa.sw.WriteLine("<th><img src=" + "\"" + "[Compi1]Proyecto2/imagenes/AST" + nombre + ".png" + "\"" + "></th>"); Programa.sw.WriteLine("</tr>"); } catch (Exception) { MessageBox.Show("No se creó el AST del " + nombre + "."); } }
static void Simple2_AnalyseLayout() { int n_images = Images.Length; int i_image = 0; for (; i_image < n_images; i_image++) { string fileName = Images[i_image]; Console.WriteLine("{0} Image: {1}", i_image, fileName); string imageFile = Path.Combine(InputFolder, fileName); string name = Path.GetFileNameWithoutExtension(imageFile); string outFile = Path.Combine(OutputFolder, string.Format("Simple2_{0}_layout.bmp", name)); string outFile2 = Path.Combine(OutputFolder, string.Format("Simple2_{0}_grey.bmp", name)); string outFile3 = Path.Combine(OutputFolder, string.Format("Simple2_{0}_bin.bmp", name)); using (TesseractProcessor processor = new TesseractProcessor()) { processor.InitForAnalysePage(); //processor.SetPageSegMode(ePageSegMode.PSM_AUTO); using (Bitmap bmp = Bitmap.FromFile(imageFile) as Bitmap) { using (GreyImage greyImage = GreyImage.FromImage(bmp)) { greyImage.Save(ImageFormat.Bmp, outFile2); ImageThresholder thresholder = new AdaptiveThresholder(); using (BinaryImage binImage = thresholder.Threshold(greyImage)) { binImage.Save(ImageFormat.Bmp, outFile3); DateTime started = DateTime.Now; DateTime ended = DateTime.Now; DocumentLayout doc = null; unsafe { started = DateTime.Now; doc = processor.AnalyseLayoutBinaryImage( binImage.BinaryData, greyImage.Width, greyImage.Height); ended = DateTime.Now; Console.WriteLine("Duration AnalyseLayout: {0} ms", (ended - started).TotalMilliseconds); } Console.WriteLine(doc.ToString()); using (Image tmp = new Bitmap(bmp.Width, bmp.Height)) // prevents one-byte index format { using (Graphics grph = Graphics.FromImage(tmp)) { Rectangle rect = new Rectangle(0, 0, tmp.Width, tmp.Height); grph.DrawImage(bmp, rect, rect, GraphicsUnit.Pixel); grph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; foreach (Block block in doc.Blocks) { Render.DrawBlock(grph, block); } } tmp.Save(outFile); } } } } } } }