Examples of JPEGTranscoder


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

        // Create the transcoder output.
        OutputStream ostream = new FileOutputStream(jpeg);
        TranscoderOutput output = new TranscoderOutput(ostream);

        // Create a JPEG transcoder
        Transcoder t = new JPEGTranscoder();

        // Set the transcoding hints.
        t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(1.0));

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

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

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

        TranscoderInput input = new TranscoderInput(svg);

        TranscoderOutput output = new TranscoderOutput(jpeg);

        // Create a JPEG transcoder
        Transcoder t = new JPEGTranscoder();

        // Set the transcoding hints.
        t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(1.0));

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

        // Flush and close the stream.
        svg.close();
        jpeg.flush();
        jpeg.close();
View Full Code Here

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

    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:
                try {
                    Class pdfClass = Class.forName("org.apache.fop.svg.PDFTranscoder");
View Full Code Here

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

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

                    // create a BufferedImage of the appropriate type
                    int w = buffer.getWidth();
                    int h = buffer.getHeight();
                    final ImageTranscoder trans = new JPEGTranscoder();
                    trans.addTranscodingHint
                        (JPEGTranscoder.KEY_XML_PARSER_CLASSNAME,
                         application.getXMLParserClassName());
                    trans.addTranscodingHint
                        (JPEGTranscoder.KEY_QUALITY, new Float(quality));

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

                    // paint the buffer to the image
                    Graphics2D g2d = img.createGraphics();
                    g2d.setColor(Color.white);
                    g2d.fillRect(0, 0, w, h);
                    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();
                                ostream.close();
                            } catch (Exception ex) { }
                            statusBar.setMessage
                                (resources.getString("Message.done"));
View Full Code Here

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

    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:
                try {
                    Class pdfClass = Class.forName("org.apache.fop.svg.PDFTranscoder");
View Full Code Here

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

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

                    // create a BufferedImage of the appropriate type
                    int w = buffer.getWidth();
                    int h = buffer.getHeight();
                    final ImageTranscoder trans = new JPEGTranscoder();
                    if (application.getXMLParserClassName() != null) {
                        trans.addTranscodingHint
                            (JPEGTranscoder.KEY_XML_PARSER_CLASSNAME,
                                application.getXMLParserClassName());
                    }
                    trans.addTranscodingHint
                        (JPEGTranscoder.KEY_QUALITY, new Float(quality));

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

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

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

        File expFile = new File(uploadTempDir, reqFilePrefix + "." + exportType);
        log.debug("exported file: " + expFile.getCanonicalPath());
        if ("svg".equals(exportType)) {
          outFile(response, expFile);
        } else if ("jpg".equals(exportType)) {
          JPEGTranscoder t = new JPEGTranscoder();
              t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, 1f);
             
              OutputStream ostream = new FileOutputStream(expFile);
              TranscoderOutput output = new TranscoderOutput(new FileOutputStream(expFile));

              // Perform the transcoding.
              t.transcode(new TranscoderInput(svgFile.toURI().toString()), output);
              ostream.flush();
              ostream.close();
             
          outFile(response, expFile);
        } else if (exportType.equals("png")
View Full Code Here

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

        File expFile = new File(uploadTempDir, reqFilePrefix + "." + exportType);
        log.debug("exported file: " + expFile.getCanonicalPath());
        if ("svg".equals(exportType)) {
          outFile(response, expFile);
        } else if ("jpg".equals(exportType)) {
          JPEGTranscoder t = new JPEGTranscoder();
              t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, 1f);
             
              OutputStream ostream = new FileOutputStream(expFile);
              TranscoderOutput output = new TranscoderOutput(new FileOutputStream(expFile));

              // Perform the transcoding.
              t.transcode(new TranscoderInput(svgFile.toURI().toString()), output);
              ostream.flush();
              ostream.close();
             
          outFile(response, expFile);
        } else if (exportType.equals("png")
View Full Code Here

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

        */
        ImageTranscoder t = null;
        if (mimeType.equals("image/jpg") ||
            mimeType.equals("image/jpeg") ||
            mimeType.equals("image/jpe")) {
            t = new JPEGTranscoder();
            t.addTranscodingHint(JPEGTranscoder.KEY_XML_PARSER_CLASSNAME,
                                 "org.apache.crimson.parser.XMLReaderImpl");
        } else if (mimeType.equals("image/png")) {
            t = new PNGTranscoder();
            t.addTranscodingHint(PNGTranscoder.KEY_XML_PARSER_CLASSNAME,
View Full Code Here

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

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

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

                    // paint the buffer to the image
                    Graphics2D g2d = img.createGraphics();
                    g2d.setColor(Color.white);
                    g2d.fillRect(0, 0, w, h);
                    g2d.drawImage(buffer, null, 0, 0);
                    new Thread() {
                        public void run() {
                            try {
                                currentExportPath = f.getCanonicalPath();
                                OutputStream ostream =
                                    new BufferedOutputStream(new FileOutputStream(f));
                                trans.writeImage(img, new TranscoderOutput(ostream));
                                ostream.flush();
                                ostream.close();
                            } catch (Exception ex) { }
                            statusBar.setMessage
                                (resources.getString("Message.done"));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.