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


Java ImageWriteParam.getCompressionTypes方法代码示例

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


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

示例1: ImageCompressionTypesTest

import javax.imageio.ImageWriteParam; //导入方法依赖的package包/类
public ImageCompressionTypesTest(String format) {
    Iterator it = ImageIO.getImageWritersByFormatName(format);
    while (it.hasNext()) {
        writer = (ImageWriter) it.next();
        break;
    }
    ImageWriteParam param = writer.getDefaultWriteParam();

    param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
    System.out.println("Checking compression types for : " + format);
    String compTypes[] = param.getCompressionTypes();
    if (compTypes.length > 1) {
        for (int i = 0; i < compTypes.length; i++) {
            for (int j = i + 1; j < compTypes.length; j++) {
                if (compTypes[i].equalsIgnoreCase(compTypes[j])) {
                    throw new RuntimeException("Duplicate compression"
                            + " type exists for image format " + format);
                }
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:ImageCompressionTypesTest.java

示例2: test4446842

import javax.imageio.ImageWriteParam; //导入方法依赖的package包/类
private static void test4446842() {
    ImageWriteParam iwp = new ImageWriteParam(null);
    try {
        iwp.getCompressionTypes();
        throw new RuntimeException("Failed to get UOE!");
    } catch (UnsupportedOperationException e) {
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:ImageWriteParamMisc.java

示例3: BMPSubsamplingTest

import javax.imageio.ImageWriteParam; //导入方法依赖的package包/类
public BMPSubsamplingTest() throws IOException {
    ImageWriter writer =
        ImageIO.getImageWritersByFormatName(format).next();

    ImageWriteParam wparam = writer.getDefaultWriteParam();
    wparam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
    String[] types = wparam.getCompressionTypes();
    for (int t = 0; t < img_types.length; t++) {
        int img_type = img_types[t];
        System.out.println("Test for " + getImageTypeName(img_type));
        BufferedImage image = getTestImage(img_type);

        ImageTypeSpecifier specifier = new ImageTypeSpecifier(image);

        if (!writer.getOriginatingProvider().canEncodeImage(specifier)) {
            System.out.println("Writer does not support encoding this buffered image type.");
            continue;
        }

        for(int i=0; i<types.length; i++) {
            if ("BI_JPEG".equals(types[i])) {
                // exclude BI_JPEG from automatic test
                // due to color diffusion effect on the borders.
                continue;
            }

            if (canEncodeImage(types[i], specifier, img_type)) {
                System.out.println("compression type: " + types[i] +
                    " Supported for " + getImageTypeName(img_type));
            } else {
                System.out.println("compression type: " + types[i] +
                    " NOT Supported for " + getImageTypeName(img_type));
                continue;
            }
            ImageWriteParam imageWriteParam = getImageWriteParam(writer, types[i]);

            imageWriteParam.setSourceSubsampling(srcXSubsampling,
                                                 srcYSubsampling,
                                                 0, 0);
            File outputFile = new File("subsampling_test_" +
                getImageTypeName(img_type) + "__" +
                types[i] + ".bmp");
            ImageOutputStream ios =
                ImageIO.createImageOutputStream(outputFile);
            writer.setOutput(ios);

            IIOImage iioImg = new IIOImage(image, null, null);

            writer.write(null, iioImg, imageWriteParam);

            ios.flush();
            ios.close();

            BufferedImage outputImage = ImageIO.read(outputFile);
            checkTestImage(outputImage);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:59,代码来源:BMPSubsamplingTest.java


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