当前位置: 首页>>代码示例>>Java>>正文


Java JPEGTranscoder类代码示例

本文整理汇总了Java中org.apache.batik.transcoder.image.JPEGTranscoder的典型用法代码示例。如果您正苦于以下问题:Java JPEGTranscoder类的具体用法?Java JPEGTranscoder怎么用?Java JPEGTranscoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JPEGTranscoder类属于org.apache.batik.transcoder.image包,在下文中一共展示了JPEGTranscoder类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTranscoder

import org.apache.batik.transcoder.image.JPEGTranscoder; //导入依赖的package包/类
/**
 * Returns a transcoder object of the result image type.
 *
 * @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:
      try {
        Class pdfClass = Class.forName("org.apache.fop.svg.PDFTranscoder");
        return (Transcoder) pdfClass.newInstance();
      }
      catch (Exception e) {
        return null;
      }
    default:
      return null;
  }

}
 
开发者ID:etomica,项目名称:etomica,代码行数:28,代码来源:DestinationType.java

示例2: getTranscoder

import org.apache.batik.transcoder.image.JPEGTranscoder; //导入依赖的package包/类
/**
 * Returns a transcoder object of the result image type.
 *
 * @return Transcoder object or <code>null</code> 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:
            try {
                Class pdfClass = Class.forName("org.apache.fop.svg.PDFTranscoder");
                return (Transcoder)pdfClass.newInstance();
            } catch(Exception e) {
                return null;
            }
        default:
            return null;
    }

}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:26,代码来源:DestinationType.java

示例3: readInput

import org.apache.batik.transcoder.image.JPEGTranscoder; //导入依赖的package包/类
protected void readInput(final PipelineContext context, final ProcessorInput input, Config config, OutputStream outputStream) {
    try {

        //JPEGTranscoder t = new JPEGTranscoder();
        final ImageTranscoder imageTranscoder = new PNGTranscoder();
        imageTranscoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(0.8));
        //t.addTranscodingHint(JPEGTranscoder.KEY_WIDTH, new Integer(100));
        //trans.addTranscodingHint(JPEGTranscoder.KEY_AOI, aoi);
        //Document document = readInputAsDOM4J(context, input);
        //String documentString = XMLUtils.domToString(document);
        //TranscoderInput ti = new TranscoderInput(new StringReader(documentString));
        //TranscoderInput tixxx1 = new TranscoderInput(document);

        final TranscoderInput transcoderInput = new TranscoderInput(new XMLReaderToReceiver() {
            @Override
            public void parse(String systemId) throws SAXException {
                readInputAsSAX(context, (input != null) ? input : getInputByName(INPUT_DATA), createXMLReceiver());
            }
        });
        final TranscoderOutput transcoderOutput = new TranscoderOutput(outputStream);
        imageTranscoder.transcode(transcoderInput, transcoderOutput);
    } catch (Exception e) {
        throw new OXFException(e);
    }
}
 
开发者ID:evlist,项目名称:orbeon-forms,代码行数:26,代码来源:SVGSerializer.java

示例4: createJpgImage

import org.apache.batik.transcoder.image.JPEGTranscoder; //导入依赖的package包/类
public byte[] createJpgImage() throws Exception {
    //*** Create a JPEGTranscoder and set its quality hint ***
    JPEGTranscoder t = new JPEGTranscoder();
    t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(.8));

    //*** Perform the transcoding ***
    return this.createImage(t);
}
 
开发者ID:glycoinfo,项目名称:eurocarbdb,代码行数:9,代码来源:SvgFactory.java

示例5: actionPerformed

import org.apache.batik.transcoder.image.JPEGTranscoder; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {
    if (svgDocument != null) {
        final SVGDocument doc = svgDocument;
        new Thread() {
            public void run(){
                String uri = doc.getURL();
                String fragment = svgCanvas.getFragmentIdentifier();
                if (fragment != null) {
                    uri += '#' +fragment;
                }

                //
                // Build a PrintTranscoder to handle printing
                // of the svgDocument object
                //
                PrintTranscoder pt = new PrintTranscoder();

                //
                // Set transcoding hints
                //
                if (application.getXMLParserClassName() != null) {
                    pt.addTranscodingHint
                        (JPEGTranscoder.KEY_XML_PARSER_CLASSNAME,
                            application.getXMLParserClassName());
                }

                pt.addTranscodingHint(PrintTranscoder.KEY_SHOW_PAGE_DIALOG,
                                      Boolean.TRUE);


                pt.addTranscodingHint(PrintTranscoder.KEY_SHOW_PRINTER_DIALOG,
                                      Boolean.TRUE);

                //
                // Do transcoding now
                //
                pt.transcode(new TranscoderInput(uri), null);

                //
                // Print
                //
                try {
                    pt.print();
                } catch (PrinterException ex) {
                    userAgent.displayError(ex);
                }
            }
        }.start();
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:51,代码来源:JSVGViewerFrame.java

示例6: exportPlot

import org.apache.batik.transcoder.image.JPEGTranscoder; //导入依赖的package包/类
/**
 * Exports the selected file to the wanted format.
 *
 * @param exportFile
 * @param imageType
 * @param svgGenerator
 * @throws IOException
 * @throws TranscoderException
 */
private static void exportPlot(File exportFile, ImageType imageType, SVGGraphics2D svgGenerator)
        throws IOException, TranscoderException {

    // write the svg file
    File svgFile = exportFile;

    if (imageType != ImageType.SVG) {
        svgFile = new File(exportFile.getAbsolutePath() + ".temp");
    }

    OutputStream outputStream = new FileOutputStream(svgFile);
    BufferedOutputStream bos = new BufferedOutputStream(outputStream);
    Writer out = new OutputStreamWriter(bos, "UTF-8");
    svgGenerator.stream(out, true /* use css */);
    outputStream.flush();
    outputStream.close();
    bos.close();

    // if selected image format is not svg, convert the image
    if (imageType != ImageType.SVG) {

        // set up the svg input
        String svgURI = svgFile.toURI().toString();
        TranscoderInput svgInputFile = new TranscoderInput(svgURI);

        OutputStream outstream = new FileOutputStream(exportFile);
        bos = new BufferedOutputStream(outstream);
        TranscoderOutput output = new TranscoderOutput(bos);

        if (imageType == ImageType.PDF) {

            // write as pdf
            Transcoder pdfTranscoder = new PDFTranscoder();
            pdfTranscoder.addTranscodingHint(PDFTranscoder.KEY_PIXEL_UNIT_TO_MILLIMETER, new Float(0.084666f));
            pdfTranscoder.transcode(svgInputFile, output);

        } else if (imageType == ImageType.JPEG) {

            // write as jpeg
            Transcoder jpegTranscoder = new JPEGTranscoder();
            jpegTranscoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(1.0));
            jpegTranscoder.transcode(svgInputFile, output);

        } else if (imageType == ImageType.TIFF) {

            // write as tiff
            Transcoder tiffTranscoder = new TIFFTranscoder();
            tiffTranscoder.addTranscodingHint(TIFFTranscoder.KEY_PIXEL_UNIT_TO_MILLIMETER, new Float(0.084666f));
            tiffTranscoder.addTranscodingHint(TIFFTranscoder.KEY_FORCE_TRANSPARENT_WHITE, true);
            tiffTranscoder.transcode(svgInputFile, output);

        } else if (imageType == ImageType.PNG) {

            // write as png
            Transcoder pngTranscoder = new PNGTranscoder();
            pngTranscoder.addTranscodingHint(PNGTranscoder.KEY_PIXEL_UNIT_TO_MILLIMETER, new Float(0.084666f));
            pngTranscoder.transcode(svgInputFile, output);

        }

        //close the stream
        outstream.flush();
        outstream.close();
        bos.close();

        // delete the svg file given that the selected format is not svg
        if (svgFile.exists()) {
            svgFile.delete();
        }
    }
}
 
开发者ID:compomics,项目名称:compomics-utilities,代码行数:81,代码来源:Export.java

示例7: exportPlot

import org.apache.batik.transcoder.image.JPEGTranscoder; //导入依赖的package包/类
/**
 * Exports the selected file to the wanted format.
 *
 * @param exportFile
 * @param imageType
 * @param svgGenerator
 * @throws IOException
 * @throws TranscoderException
 */
private static void exportPlot(File exportFile, ImageType imageType, SVGGraphics2D svgGenerator)
        throws IOException, TranscoderException {

    // write the svg file
    File svgFile = exportFile;

    if (imageType != ImageType.SVG) {
        svgFile = new File(exportFile.getAbsolutePath() + ".temp");
    }

    OutputStream outputStream = new FileOutputStream(svgFile);
    Writer out = new OutputStreamWriter(outputStream, "UTF-8");
    svgGenerator.stream(out, true /* use css */);
    outputStream.flush();
    outputStream.close();

    // if selected image format is not svg, convert the image
    if (imageType != ImageType.SVG) {

        // set up the svg input
        String svgURI = svgFile.toURI().toString();
        TranscoderInput svgInputFile = new TranscoderInput(svgURI);

        OutputStream outstream = new FileOutputStream(exportFile);
        TranscoderOutput output = new TranscoderOutput(outstream);

        if (imageType == ImageType.PDF) {

            // write as pdf
            Transcoder pdfTranscoder = new PDFTranscoder();
            pdfTranscoder.addTranscodingHint(PDFTranscoder.KEY_PIXEL_UNIT_TO_MILLIMETER, new Float(0.084666f));
            pdfTranscoder.transcode(svgInputFile, output);

        } else if (imageType == ImageType.JPEG) {

            // write as jpeg
            Transcoder jpegTranscoder = new JPEGTranscoder();
            jpegTranscoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(1.0));
            jpegTranscoder.transcode(svgInputFile, output);

        } else if (imageType == ImageType.TIFF) {

            // write as tiff
            Transcoder tiffTranscoder = new TIFFTranscoder();
            tiffTranscoder.addTranscodingHint(TIFFTranscoder.KEY_PIXEL_UNIT_TO_MILLIMETER, new Float(0.084666f));
            tiffTranscoder.addTranscodingHint(TIFFTranscoder.KEY_FORCE_TRANSPARENT_WHITE, true);
            tiffTranscoder.transcode(svgInputFile, output);

        } else if (imageType == ImageType.PNG) {

            // write as png
            Transcoder pngTranscoder = new PNGTranscoder();
            pngTranscoder.addTranscodingHint(PNGTranscoder.KEY_PIXEL_UNIT_TO_MILLIMETER, new Float(0.084666f));
            pngTranscoder.transcode(svgInputFile, output);

        }

        //close the stream
        outstream.flush();
        outstream.close();

        // delete the svg file given that the selected format is not svg
        if (svgFile.exists()) {
            svgFile.delete();
        }
    }
}
 
开发者ID:compomics,项目名称:mitraq,代码行数:77,代码来源:Export.java

示例8: saveAsJPEG

import org.apache.batik.transcoder.image.JPEGTranscoder; //导入依赖的package包/类
/**
 * Transcode file to JPEG.
 *
 * @param file Output filename
 * @param width Width
 * @param height Height
 * @param quality JPEG quality setting, between 0.0 and 1.0
 * @throws IOException On write errors
 * @throws TranscoderException On input/parsing errors.
 */
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);
}
 
开发者ID:elki-project,项目名称:elki,代码行数:18,代码来源:SVGPlot.java


注:本文中的org.apache.batik.transcoder.image.JPEGTranscoder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。