Package org.apache.batik.transcoder.image

Examples of org.apache.batik.transcoder.image.PNGTranscoder


   * @throws IOException Failed to transform the SVG doc into an image
   */
  public void transform(org.wso2.carbon.bpel.ui.bpel2svg.SVGInterface svg,
            java.io.OutputStream os) throws IOException {
        // Create a PNG transcoder
        PNGTranscoder pngTranscoder = new PNGTranscoder();
       
        // Create the transcoder input.
        String inputString = svg.getHeaders() + svg.generateSVGString();
       
        //SVGDocument svgDoc = svg.getRootActivity().getSVGDocument();
       
        //TranscoderInput transcoderInput = new TranscoderInput(svgDoc);
        Reader stringReader = new StringReader(inputString);
        TranscoderInput transcoderInput = new TranscoderInput(stringReader);
       
        // Create the transcoder output.
        TranscoderOutput transcoderOutput = new TranscoderOutput(os);
        try {
            pngTranscoder.transcode(transcoderInput, transcoderOutput);
        } catch (TranscoderException te) {
          // code compatible with jdk 1.5
            IOException ioe = new IOException("Transcoder error");
            ioe.initCause(te);
            throw ioe;
View Full Code Here


    SVGAbstractTranscoder transcoder = null;

    switch (mime) {
    case PNG:
      transcoder = new PNGTranscoder();
      break;
    case JPEG:
      transcoder = new JPEGTranscoder();
      transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY,
          new Float(0.9));
View Full Code Here

  private class TransformSVGToPNG {

    File transformAndCopy(File svgFile, File targetDir) {
      String pngFileName = FilenameUtils.getBaseName(svgFile.getPath()) + ".png";
      File pngFile = new File(targetDir, pngFileName);
      PNGTranscoder t = new PNGTranscoder();
     
      try {
        TranscoderInput input = new TranscoderInput(svgFile.toURI().toString());
        pngFile.createNewFile();
       
        OutputStream ostream = new FileOutputStream(pngFile);
        TranscoderOutput output = new TranscoderOutput(ostream);
       
        t.transcode(input, output);
        ostream.flush();
        ostream.close();
       
        return pngFile;
      } catch (IOException e) {
View Full Code Here


    public void rasterize() throws RuntimeException{
        try{
        // Create a JPEG transcoder
        PNGTranscoder t = new PNGTranscoder();

        // Set the transcoding hints.
       // t.addTranscodingHint(PNGTranscoder.KEY_QUALITY,
         //                    new Float(.8));

        // Create the transcoder input.
        String svgURI = new File("/Users/nare4013/epub/rackspace-template/rackspace-template/target/docbkx/images/cloud/cover.svg").toURI().toURL().toString();
        TranscoderInput input = new TranscoderInput(svgURI);

        // Create the transcoder output.
        OutputStream ostream = new FileOutputStream("/Users/nare4013/epub/rackspace-template/rackspace-template/target/docbkx/images/cloud/cover.png");
        TranscoderOutput output = new TranscoderOutput(ostream);

        // Save the image.
        t.transcode(input, output);

        // Flush and close the stream.
        ostream.flush();
        ostream.close();
        }
View Full Code Here

      // compare the resulting image with the reference image
      // state = true if refImg is the same than img

            ByteArrayOutputStream out = new ByteArrayOutputStream();
            TranscoderOutput output = new TranscoderOutput(out);
            PNGTranscoder t = new PNGTranscoder();
            t.writeImage(img, output);
            byte [] imgData = out.toByteArray();

            if (refImgData == null) {
                report.setErrorCode(ERROR_IMAGE_DIFFER);
                report.addDescriptionEntry(ERROR_IMAGE_DIFFER, "");
View Full Code Here

       
        TranscoderOutput validDst
            = new TranscoderOutput(new FileOutputStream(tmpFile));
       
        ImageTranscoder transcoder
            = new PNGTranscoder();
       
        transcoder.transcode(validSrc, validDst);
       
        tmpFile.deleteOnExit();
       
        return tmpFile.toURL();
    }
View Full Code Here

                        (resources.getString("Message.exportAsPNG"));

                    // create a BufferedImage of the appropriate type
                    int w = buffer.getWidth();
                    int h = buffer.getHeight();
                    final ImageTranscoder trans = new PNGTranscoder();
                    trans.addTranscodingHint(PNGTranscoder.KEY_XML_PARSER_CLASSNAME,
                                             application.getXMLParserClassName());
                    trans.addTranscodingHint(PNGTranscoder.KEY_FORCE_TRANSPARENT_WHITE,
                                             new Boolean(true));

        // Start: By Jun Inamori
        if(isIndexed){
      trans.addTranscodingHint
                            (PNGTranscoder.KEY_INDEXED,new Integer(256));
        }
        // End: By Jun Inamori

                    final BufferedImage img = trans.createImage(w, h);

                    // paint the buffer to the image
                    Graphics2D g2d = img.createGraphics();
                    g2d.drawImage(buffer, null, 0, 0);
                    new Thread() {
                        public void run() {
                            try {
                                currentExportPath = f;
                                OutputStream ostream =
                                    new BufferedOutputStream(new FileOutputStream(f));
                                trans.writeImage(img,
                                                 new TranscoderOutput(ostream));
                                ostream.flush();
                            } catch (Exception ex) {}
                            statusBar.setMessage
                                (resources.getString("Message.done"));
View Full Code Here

     * @return Transcoder object or <tt>null</tt> if there isn't a proper transcoder.
     */
    protected Transcoder getTranscoder(){
        switch(code) {
            case PNG_CODE:
                return new PNGTranscoder();
            case JPEG_CODE:
                return new JPEGTranscoder();
            case TIFF_CODE:
                return new TIFFTranscoder();
            case PDF_CODE:
View Full Code Here

                        (resources.getString("Message.exportAsPNG"));

                    // create a BufferedImage of the appropriate type
                    int w = buffer.getWidth();
                    int h = buffer.getHeight();
                    final ImageTranscoder trans = new PNGTranscoder();
                    trans.addTranscodingHint(PNGTranscoder.KEY_XML_PARSER_CLASSNAME,
                                             application.getXMLParserClassName());
                    trans.addTranscodingHint(PNGTranscoder.KEY_FORCE_TRANSPARENT_WHITE,
                                             new Boolean(true));

        // Start: By Jun Inamori
        if(isIndexed){
      trans.addTranscodingHint
                            (PNGTranscoder.KEY_INDEXED,new Boolean(true));
        }
        // End: By Jun Inamori

                    final BufferedImage img = trans.createImage(w, h);

                    // paint the buffer to the image
                    Graphics2D g2d = img.createGraphics();
                    g2d.drawImage(buffer, null, 0, 0);
                    new Thread() {
                        public void run() {
                            try {
                                currentExportPath = f;
                                OutputStream ostream =
                                    new BufferedOutputStream(new FileOutputStream(f));
                                trans.writeImage(img,
                                                 new TranscoderOutput(ostream));
                                ostream.flush();
                            } catch (Exception ex) {}
                            statusBar.setMessage
                                (resources.getString("Message.done"));
View Full Code Here

                        (resources.getString("Message.exportAsPNG"));

                    // create a BufferedImage of the appropriate type
                    int w = buffer.getWidth();
                    int h = buffer.getHeight();
                    final ImageTranscoder trans = new PNGTranscoder();
                    trans.addTranscodingHint(PNGTranscoder.KEY_XML_PARSER_CLASSNAME,
                                             application.getXMLParserClassName());
                    trans.addTranscodingHint(PNGTranscoder.KEY_FORCE_TRANSPARENT_WHITE,
                                             new Boolean(true));
                    final BufferedImage img = trans.createImage(w, h);

                    // paint the buffer to the image
                    Graphics2D g2d = img.createGraphics();
                    g2d.drawImage(buffer, null, 0, 0);
                    new Thread() {
                        public void run() {
                            try {
                                currentExportPath = f;
                                OutputStream ostream =
                                    new BufferedOutputStream(new FileOutputStream(f));
                                trans.writeImage(img,
                                                 new TranscoderOutput(ostream));
                                ostream.flush();
                            } catch (Exception ex) {}
                            statusBar.setMessage
                                (resources.getString("Message.done"));
View Full Code Here

TOP

Related Classes of org.apache.batik.transcoder.image.PNGTranscoder

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.