• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TIFFTranscoder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getTranscoder

import org.apache.batik.transcoder.image.TIFFTranscoder; //导入依赖的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.TIFFTranscoder; //导入依赖的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: createCloud

import org.apache.batik.transcoder.image.TIFFTranscoder; //导入依赖的package包/类
public static byte[] createCloud(WordCloudRenderer renderer, String format)
{
    if ("svg".equalsIgnoreCase(format))
        return createSVG(renderer);
    if ("pdf".equalsIgnoreCase(format))
        return createVector(renderer, new PDFTranscoder());
    if ("eps".equalsIgnoreCase(format))
        return createVector(renderer, new EPSTranscoder());
    if ("ps".equalsIgnoreCase(format))
        return createVector(renderer, new PSTranscoder());
    if ("tif".equalsIgnoreCase(format))
        return createVector(renderer, new TIFFTranscoder());
    else if ("png".equalsIgnoreCase(format) || "bmp".equalsIgnoreCase(format) || "gif".equalsIgnoreCase(format))
        return createBitmap(renderer, format);
    else if ("jpeg".equalsIgnoreCase(format) || "jpg".equalsIgnoreCase(format))
        return createBitmap(renderer, "jpeg");

    throw new RuntimeException("unrecognized format '" + format + "'");
}
 
开发者ID:spupyrev,项目名称:swcv,代码行数:20,代码来源:RenderUtils.java


示例4: actionPerformed

import org.apache.batik.transcoder.image.TIFFTranscoder; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {
    JFileChooser fileChooser =
        new JFileChooser(makeAbsolute(currentSavePath));
    fileChooser.setDialogTitle(resources.getString("ExportAsTIFF.title"));
    fileChooser.setFileHidingEnabled(false);
    fileChooser.setFileSelectionMode
        (JFileChooser.FILES_ONLY);
    fileChooser.addChoosableFileFilter(new ImageFileFilter(".tiff"));

    int choice = fileChooser.showSaveDialog(JSVGViewerFrame.this);
    if (choice == JFileChooser.APPROVE_OPTION) {
        final File f = fileChooser.getSelectedFile();
        BufferedImage buffer = svgCanvas.getOffScreen();
        if (buffer != null) {
            statusBar.setMessage
                (resources.getString("Message.exportAsTIFF"));

            // create a BufferedImage of the appropriate type
            int w = buffer.getWidth();
            int h = buffer.getHeight();
            final ImageTranscoder trans = new TIFFTranscoder();
            if (application.getXMLParserClassName() != null) {
                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.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"));
                }
            }.start();
        }
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:49,代码来源:JSVGViewerFrame.java


示例5: exportPlot

import org.apache.batik.transcoder.image.TIFFTranscoder; //导入依赖的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


示例6: exportPlot

import org.apache.batik.transcoder.image.TIFFTranscoder; //导入依赖的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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Membership类代码示例发布时间:2022-05-23
下一篇:
Java WSDLBoundPortType类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap