Package org.apache.batik.transcoder.image

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


      // 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

     * @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();
                    if (application.getXMLParserClassName() != null) {
                        trans.addTranscodingHint
                            (JPEGTranscoder.KEY_XML_PARSER_CLASSNAME,
                                application.getXMLParserClassName());
                    }
                    trans.addTranscodingHint(PNGTranscoder.KEY_FORCE_TRANSPARENT_WHITE,
                                             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 {
                                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

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

   * @param height Height
   * @throws IOException On write errors
   * @throws TranscoderException On input/parsing errors.
   */
  public void saveAsPNG(File file, int width, int height) throws IOException, TranscoderException {
    PNGTranscoder t = new PNGTranscoder();
    t.addTranscodingHint(PNGTranscoder.KEY_WIDTH, new Float(width));
    t.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, new Float(height));
    transcode(file, t);
  }
View Full Code Here

   * @param height Height
   * @throws IOException On write errors
   * @throws TranscoderException On input/parsing errors.
   */
  public void saveAsPNG(File file, int width, int height) throws IOException, TranscoderException {
    PNGTranscoder t = new PNGTranscoder();
    t.addTranscodingHint(PNGTranscoder.KEY_WIDTH, new Float(width));
    t.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, new Float(height));
    transcode(file, t);
  }
View Full Code Here

      repositoryService.addModelEditorSource(model.getId(), values.getFirst("json_xml").getBytes("utf-8"));
     
      InputStream svgStream = new ByteArrayInputStream(values.getFirst("svg_xml").getBytes("utf-8"));
      TranscoderInput input = new TranscoderInput(svgStream);
     
      PNGTranscoder transcoder = new PNGTranscoder();
      // Setup output
      ByteArrayOutputStream outStream = new ByteArrayOutputStream();
      TranscoderOutput output = new TranscoderOutput(outStream);
     
      // Do the transformation
      transcoder.transcode(input, output);
      final byte[] result = outStream.toByteArray();
      repositoryService.addModelEditorSourceExtra(model.getId(), result);
      outStream.close();
     
    } catch (Exception e) {
View Full Code Here

      t.addTranscodingHint(JPEGTranscoder.KEY_WIDTH, new Float(width));
      // } else if (imageFormat == ImageFormat.TIFF) {
      // t = new TIFFTranscoder();
      // t.addTranscodingHint(TIFFTranscoder.KEY_WIDTH, new Float(width));
    } else {
      t = new PNGTranscoder();
      t.addTranscodingHint(PNGTranscoder.KEY_WIDTH, new Float(width));
    }
    // Set the transcoding hints.
    TranscoderInput input = new TranscoderInput(document);
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

   * @return true for successful conversion, false otherwise
   */
  public boolean convert( String name, InputStream is, OutputStream os, int width, int height )
  {
    try {
      PNGTranscoder trans = new PNGTranscoder();
      trans.addTranscodingHint( PNGTranscoder.KEY_WIDTH, new Float( width ));
      trans.addTranscodingHint( PNGTranscoder.KEY_HEIGHT, new Float( height ));           
      TranscoderInput input = new TranscoderInput( is );
      TranscoderOutput output = new TranscoderOutput( os );
      trans.transcode( input, output );
      os.flush();
      os.close();
    }
    catch ( NoClassDefFoundError e ) { 
        e.printStackTrace();
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.