Package org.stathissideris.ascii2image.graphics

Examples of org.stathissideris.ascii2image.graphics.BitmapRenderer$TextCanvas


     
      Diagram diagram = new Diagram(grid, options);
      if (!stdOut) System.out.println("Rendering to file: "+toFilename);
     
     
      RenderedImage image = new BitmapRenderer().renderToImage(diagram, options.renderingOptions);
     
      try {
        OutputStream os = stdOut ? System.out : new FileOutputStream(toFilename);
        ImageIO.write(image, "png", os);
      } catch (IOException e) {
View Full Code Here


      }
    } catch (UnsupportedEncodingException e1) {
      error("Cannot initialize text grid");
    }
    Diagram diagram = new Diagram(textGrid, options);
    RenderedImage image = new BitmapRenderer().renderToImage(diagram,
        options.renderingOptions);

    try {
      ImageIO.write(image, "png", outputFile);
    } catch (IOException e) {
View Full Code Here

        System.err.println("Error: "+e1.getMessage());
        System.exit(1);
      }

      Diagram diagram = new Diagram(grid, options);
      RenderedImage image = new BitmapRenderer().renderToImage(diagram, options.renderingOptions);

      try {
        File file = new File(imageFilename);
        ImageIO.write(image, "png", file);
      } catch (IOException e) {
View Full Code Here

   
    TextGrid grid = new TextGrid();
    grid.loadFrom(textFile.toString());
    Diagram diagram = new Diagram(grid, options);

    RenderedImage image = new BitmapRenderer().renderToImage(diagram, options.renderingOptions);   
 
    File file = new File(actualFile.getAbsolutePath());
    ImageIO.write(image, "png", file);
   
    //compare images pixel-by-pixel
View Full Code Here

        System.out.println("Rendering "+textFile+" to "+toFile);
       
        grid.loadFrom(textFile.toString());
        Diagram diagram = new Diagram(grid, options);

        RenderedImage image = new BitmapRenderer().renderToImage(diagram, options.renderingOptions);
       
        b = java.lang.System.nanoTime();
            java.lang.System.out.println( "Done in " + Math.round((b - a)/10e6) + "msec");
       
        try {
View Full Code Here

        System.out.println("Rendering "+textFile+" to "+toFile);
       
        grid.loadFrom(textFile.toString());
        Diagram diagram = new Diagram(grid, options);

        RenderedImage image = new BitmapRenderer().renderToImage(diagram, options.renderingOptions);
       
        b = java.lang.System.nanoTime();
            java.lang.System.out.println( "Done in " + Math.round((b - a)/10e6) + "msec");
       
        try {
View Full Code Here

            public RenderedImage call() throws Exception {
                grid.initialiseWithText(gridText, options.processingOptions);
                grid.printDebug();

                Diagram diagram = new Diagram(grid, options);
                return new BitmapRenderer().renderToImage(diagram, options.renderingOptions);
            }
        });
        try {
            RenderedImage image = future.get(timeoutSeconds, TimeUnit.SECONDS);
            response.setContentType("image/png");
View Full Code Here

        grid.printDebug();

        long start = System.currentTimeMillis();
        Diagram diagram = new Diagram(grid, options);
        final RenderedImage image = new BitmapRenderer().renderToImage(diagram, options.renderingOptions);
        System.out.println("0. Rendered in " + (System.currentTimeMillis() - start) + " ms");
//        ImageIO.write(image, "png", os);

        JFrame frame = new JFrame("Ditaa Test");
        frame.setSize(image.getWidth()+30, image.getHeight()+80);
        Panel panel = new Panel() {
            public void paint(Graphics g) {
                g.drawImage((Image) image, 0, 0, null);
            }
        };
        frame.getContentPane().add(panel);
        panel.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                System.out.println("Mouse clicked.");
                System.exit(0);
            }
        });
        // this doesn't seem to be working:
        frame.addWindowStateListener(new WindowStateListener() {
            public void windowStateChanged(WindowEvent e) {
                System.out.println("Window state changed: " + e.getNewState());
                if (e.getNewState() == WindowEvent.WINDOW_CLOSED)
                    System.exit(0);
            }
        });
        frame.setVisible(true);

        for (int i = 0; i < 10; ++i) {
            start = System.currentTimeMillis();
            Diagram nDiagram = new Diagram(grid, options);
            new BitmapRenderer().renderToImage(nDiagram, options.renderingOptions);
            System.out.println((i+1) + ". Rendered in " + (System.currentTimeMillis() - start) + " ms");
        }
    }
View Full Code Here

            for (int i = 0; i  < linesArray.length; i++) {
                lines.add(new StringBuffer(linesArray[i]));
            }
            grid.initialiseWithLines(lines, options.processingOptions);
            Diagram diagram = new Diagram(grid, options);
            RenderedImage image = new BitmapRenderer().renderToImage(diagram, options.renderingOptions);

            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ImageIO.write(image, "png", baos);
            base64 = Base64.encodeBytes(baos.toByteArray(), 0, baos.size());
        } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.stathissideris.ascii2image.graphics.BitmapRenderer$TextCanvas

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.