Package org.apache.batik.transcoder.image

Examples of org.apache.batik.transcoder.image.JPEGTranscoder.addTranscodingHint()


   */
  public void saveAsJPEG(File file, int width, int height, double quality) throws IOException, TranscoderException {
    JPEGTranscoder t = new JPEGTranscoder();
    t.addTranscodingHint(JPEGTranscoder.KEY_WIDTH, new Float(width));
    t.addTranscodingHint(JPEGTranscoder.KEY_HEIGHT, new Float(height));
    t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(quality));
    transcode(file, t);
  }

  /**
   * Transcode file to JPEG.
View Full Code Here


     * @param image the SVG image
     * @return a byte array containing the JPEG image
     */
    public static byte[] convertToJPEG(XMLImage image) {
        JPEGTranscoder transcoder = new JPEGTranscoder();
        transcoder.addTranscodingHint(ImageTranscoder.KEY_PIXEL_UNIT_TO_MILLIMETER,
                new Float(25.4f / 300)); //300dpi should be enough for now.
        transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(0.9f));
        TranscoderInput input = new TranscoderInput(image.getDocument());
        ByteArrayOutputStream baout = new ByteArrayOutputStream(16384);
        TranscoderOutput output = new TranscoderOutput(baout);
View Full Code Here

     */
    public static byte[] convertToJPEG(XMLImage image) {
        JPEGTranscoder transcoder = new JPEGTranscoder();
        transcoder.addTranscodingHint(ImageTranscoder.KEY_PIXEL_UNIT_TO_MILLIMETER,
                new Float(25.4f / 300)); //300dpi should be enough for now.
        transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(0.9f));
        TranscoderInput input = new TranscoderInput(image.getDocument());
        ByteArrayOutputStream baout = new ByteArrayOutputStream(16384);
        TranscoderOutput output = new TranscoderOutput(baout);
        try {
            transcoder.transcode(input, output);
View Full Code Here

                    // 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));
       
View Full Code Here

                    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
View Full Code Here

                    // 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));
       
View Full Code Here

                    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
View Full Code Here

                    // 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();
View Full Code Here

                    // 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();
View Full Code Here

                        System.err.println(dir.listFiles()[k].getAbsolutePath());
                        MDLV2000Reader reader = new MDLV2000Reader(new FileInputStream(dir.listFiles()[k]), Mode.RELAXED);
                        IAtomContainer cdkmol = (IAtomContainer)reader.read(DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class));
                        String inputstr = getMolSvg(cdkmol, 100, 100);
                        ImageTranscoder imageTranscoder = new JPEGTranscoder();
                        imageTranscoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(.8));
                        TranscoderInput input = new TranscoderInput(new StringReader(inputstr));
                        FileOutputStream ostream = new FileOutputStream(new File(dir.listFiles()[k].getAbsolutePath().substring(0,dir.listFiles()[k].getAbsolutePath().length()-4)+".png"));
                        TranscoderOutput output = new TranscoderOutput(ostream);
                        imageTranscoder.transcode(input, output);
                        ostream.flush();
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.