當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。