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


Java ImageTypeSpecifier.createFromBufferedImageType方法代码示例

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


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

示例1: main

import javax.imageio.ImageTypeSpecifier; //导入方法依赖的package包/类
public static void main(String[] args) {
    int biType = BufferedImage.TYPE_USHORT_565_RGB;
    ImageTypeSpecifier type =
        ImageTypeSpecifier.createFromBufferedImageType(biType);

    int b0 = type.getBitsPerBand(0);
    int b1 = type.getBitsPerBand(1);
    int b2 = type.getBitsPerBand(2);

    if (b0 != 5 || b1 != 6 || b2 != 5) {
        throw new RuntimeException("Got incorrect bits per band value!");
    }

    boolean gotIAE = false;
    try {
        int b3 = type.getBitsPerBand(3);
    } catch (IllegalArgumentException e) {
        gotIAE = true;
    }
    if (!gotIAE) {
        throw new RuntimeException
            ("Failed to get IllegalArgumentException for band == 3!");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:ImageTypeSpecifierBitsPerBand.java

示例2: main

import javax.imageio.ImageTypeSpecifier; //导入方法依赖的package包/类
public static void main(String[] args) {
    ImageWriter w = ImageIO.getImageWritersByFormatName(format).next();
    if (w == null) {
        throw new RuntimeException("No available writers for format " + format);
    }
    ImageWriteParam p = w.getDefaultWriteParam();

    ImageTypeSpecifier t =
            ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB);

    IIOMetadata m = w.getDefaultImageMetadata(t, p);
    System.out.println("Default image metadata is " + m);
    testWritableMetadata(m);

    IIOMetadata sm = w.getDefaultStreamMetadata(p);
    System.out.println("Default stream metadata is " + sm);
    testWritableMetadata(sm);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:WriteMetadataTest.java

示例3: main

import javax.imageio.ImageTypeSpecifier; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    ImageWriter iw =
        (ImageWriter)ImageIO.getImageWritersByFormatName("jpeg").next();

    ImageTypeSpecifier type =
        ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB);

    ImageOutputStream ios =
        ImageIO.createImageOutputStream(new File("MergeTreeTest.jpeg"));
    iw.setOutput(ios);

    IIOMetadata meta = iw.getDefaultImageMetadata(type, null);

    boolean isFailed = false;

    String[] fmts = meta.getMetadataFormatNames();
    for (int i=0; i<fmts.length; i++) {
        System.out.print("Format: " + fmts[i] + " ... ");
        Node root = meta.getAsTree(fmts[i]);
        try {
            meta.mergeTree(fmts[i], root);
        } catch (NullPointerException e) {
            throw new RuntimeException("Test failed for format " + fmts[i], e);
        }
        System.out.println("PASSED");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:MergeTreeTest.java

示例4: getWriteParam

import javax.imageio.ImageTypeSpecifier; //导入方法依赖的package包/类
public ImageWriteParam getWriteParam() {
    ImageWriteParam p =  w.getDefaultWriteParam();
    p.setSourceBands(new int[] {0, 1, 2});
    ImageTypeSpecifier type =
        ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB);
    p.setDestinationType(type);

    return p;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:DestTypeTest.java

示例5: produce

import javax.imageio.ImageTypeSpecifier; //导入方法依赖的package包/类
protected ImageTypeSpecifier produce() {
    switch (csCode) {
        case JPEG.JCS_GRAYSCALE:
            return ImageTypeSpecifier.createFromBufferedImageType
                    (BufferedImage.TYPE_BYTE_GRAY);
        case JPEG.JCS_RGB:
            return ImageTypeSpecifier.createInterleaved(JPEG.JCS.sRGB,
                    JPEG.bOffsRGB,
                    DataBuffer.TYPE_BYTE,
                    false,
                    false);
        case JPEG.JCS_RGBA:
            return ImageTypeSpecifier.createPacked(JPEG.JCS.sRGB,
                    0xff000000,
                    0x00ff0000,
                    0x0000ff00,
                    0x000000ff,
                    DataBuffer.TYPE_INT,
                    false);
        case JPEG.JCS_YCC:
            if (JPEG.JCS.getYCC() != null) {
                return ImageTypeSpecifier.createInterleaved(
                        JPEG.JCS.getYCC(),
                    JPEG.bandOffsets[2],
                    DataBuffer.TYPE_BYTE,
                    false,
                    false);
            } else {
                return null;
            }
        case JPEG.JCS_YCCA:
            if (JPEG.JCS.getYCC() != null) {
                return ImageTypeSpecifier.createInterleaved(
                        JPEG.JCS.getYCC(),
                    JPEG.bandOffsets[3],
                    DataBuffer.TYPE_BYTE,
                    true,
                    false);
            } else {
                return null;
            }
        default:
            return null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:46,代码来源:JPEGImageReader.java

示例6: produce

import javax.imageio.ImageTypeSpecifier; //导入方法依赖的package包/类
protected ImageTypeSpecifier produce() {
    switch (csCode) {
        case JPEG.JCS_GRAYSCALE:
            return ImageTypeSpecifier.createFromBufferedImageType
                    (BufferedImage.TYPE_BYTE_GRAY);
        case JPEG.JCS_YCbCr:
        //there is no YCbCr raw type so by default we assume it as RGB
        case JPEG.JCS_RGB:
            return ImageTypeSpecifier.createInterleaved(JPEG.JCS.sRGB,
                    JPEG.bOffsRGB,
                    DataBuffer.TYPE_BYTE,
                    false,
                    false);
        case JPEG.JCS_RGBA:
            return ImageTypeSpecifier.createPacked(JPEG.JCS.sRGB,
                    0xff000000,
                    0x00ff0000,
                    0x0000ff00,
                    0x000000ff,
                    DataBuffer.TYPE_INT,
                    false);
        case JPEG.JCS_YCC:
            if (JPEG.JCS.getYCC() != null) {
                return ImageTypeSpecifier.createInterleaved(
                        JPEG.JCS.getYCC(),
                    JPEG.bandOffsets[2],
                    DataBuffer.TYPE_BYTE,
                    false,
                    false);
            } else {
                return null;
            }
        case JPEG.JCS_YCCA:
            if (JPEG.JCS.getYCC() != null) {
                return ImageTypeSpecifier.createInterleaved(
                        JPEG.JCS.getYCC(),
                    JPEG.bandOffsets[3],
                    DataBuffer.TYPE_BYTE,
                    true,
                    false);
            } else {
                return null;
            }
        default:
            return null;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:48,代码来源:JPEGImageReader.java


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