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


Java ImageIO.getWriterFileSuffixes方法代码示例

本文整理汇总了Java中javax.imageio.ImageIO.getWriterFileSuffixes方法的典型用法代码示例。如果您正苦于以下问题:Java ImageIO.getWriterFileSuffixes方法的具体用法?Java ImageIO.getWriterFileSuffixes怎么用?Java ImageIO.getWriterFileSuffixes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.imageio.ImageIO的用法示例。


在下文中一共展示了ImageIO.getWriterFileSuffixes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: save

import javax.imageio.ImageIO; //导入方法依赖的package包/类
@Override
public void save() throws IOException {
    FileChooserBuilder fchb = new FileChooserBuilder(ScreenshotComponent.class);
    String[] writerFileSuffixes = ImageIO.getWriterFileSuffixes();
    fchb.setFileFilter(new FileNameExtensionFilter(Bundle.CTL_ImageFiles(), writerFileSuffixes));
    File file = fchb.showSaveDialog();
    if (file != null) {
        if (file.exists()) {
            NotifyDescriptor nd = new NotifyDescriptor.Confirmation(Bundle.MSG_Overwrite(file.getName()), toString());
            Object doOverwrite = DialogDisplayer.getDefault().notify(nd);
            if (!NotifyDescriptor.YES_OPTION.equals(doOverwrite)) {
                return ;
            }
        }
        canvas.save(file);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ScreenshotComponent.java

示例2: testGetWriterFileSuffixes

import javax.imageio.ImageIO; //导入方法依赖的package包/类
private static void testGetWriterFileSuffixes() {
    String[] suffixes = ImageIO.getWriterFileSuffixes();
    for (String s : suffixes) {
        Iterator<ImageWriter> it = ImageIO.getImageWritersBySuffix(s);
        if (!it.hasNext()) {
            throw new RuntimeException("getWriterFileSuffixes returned " +
                                       "an unknown suffix: " + s);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:GetReaderWriterInfo.java

示例3: main

import javax.imageio.ImageIO; //导入方法依赖的package包/类
public static void main(String[] args) {
    Locale.setDefault(Locale.US);

    final BufferedImage image
        = new BufferedImage(512, 512, BufferedImage.TYPE_INT_ARGB);

    final Graphics2D g2d = image.createGraphics();
    try {
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                             RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
                             RenderingHints.VALUE_RENDER_QUALITY);
        g2d.scale(2.0, 2.0);

        g2d.setColor(Color.red);
        g2d.draw(new Rectangle2D.Float(10, 10, 100, 100));
        g2d.setColor(Color.blue);
        g2d.fill(new Rectangle2D.Float(12, 12, 98, 98));
        g2d.setColor(Color.green);
        g2d.setFont(new Font(Font.SERIF, Font.BOLD, 14));

        for (int i = 0; i < 15; i++) {
            g2d.drawString("Testing Compression ...", 20, 20 + i * 16);
        }

        final String[] fileSuffixes = ImageIO.getWriterFileSuffixes();

        final Set<String> testedWriterClasses = new HashSet<String>();

        for (String suffix : fileSuffixes) {

            if (!IGNORE_FILE_SUFFIXES.contains(suffix)) {
                final Iterator<ImageWriter> itWriters
                    = ImageIO.getImageWritersBySuffix(suffix);

                final ImageWriter writer;
                final ImageWriteParam writerParams;

                if (itWriters.hasNext()) {
                    writer = itWriters.next();

                    if (testedWriterClasses.add(writer.getClass().getName())) {
                        writerParams = writer.getDefaultWriteParam();

                        if (writerParams.canWriteCompressed()) {
                            testCompression(image, writer, writerParams, suffix);
                        }
                    }
                } else {
                    throw new RuntimeException("Unable to get writer !");
                }
            }
        }
    } catch (IOException ioe) {
        throw new RuntimeException("IO failure", ioe);
    }
    finally {
        g2d.dispose();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:61,代码来源:ImageWriterCompressionTest.java


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