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


Java IIOMetadata.isStandardMetadataFormatSupported方法代码示例

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


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

示例1: convertStandardImageMetadata

import javax.imageio.metadata.IIOMetadata; //导入方法依赖的package包/类
/**
 * Converts a standard {@code javax_imageio_1.0} tree to a
 * {@code TIFFImageMetadata} object.
 *
 * @param inData The metadata object.
 * @return a {@code TIFFImageMetadata} or {@code null} if
 * the standard tree derived from the input object is {@code null}.
 * @throws IllegalArgumentException if {@code inData} is
 * {@code null}.
 * @throws IllegalArgumentException if {@code inData} does not support
 * the standard metadata format.
 * @throws IIOInvalidTreeException if {@code inData} generates an
 * invalid standard metadata tree.
 */
private TIFFImageMetadata convertStandardImageMetadata(IIOMetadata inData)
    throws IIOInvalidTreeException {

    if(inData == null) {
        throw new NullPointerException("inData == null!");
    } else if(!inData.isStandardMetadataFormatSupported()) {
        throw new IllegalArgumentException
            ("inData does not support standard metadata format!");
    }

    TIFFImageMetadata outData = null;

    String formatName = IIOMetadataFormatImpl.standardMetadataFormatName;
    Node tree = inData.getAsTree(formatName);
    if (tree != null) {
        List<TIFFTagSet> tagSets = new ArrayList<TIFFTagSet>(1);
        tagSets.add(BaselineTIFFTagSet.getInstance());
        outData = new TIFFImageMetadata(tagSets);
        outData.setFromTree(formatName, tree);
    }

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

示例2: main

import javax.imageio.metadata.IIOMetadata; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    // Generate some trivial image and save it to a temporary array
    ByteArrayOutputStream tmp = new ByteArrayOutputStream();
    ImageIO.write(new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB),
            "gif", tmp);

    // Read the stream
    ImageInputStream in = new MemoryCacheImageInputStream(
            new ByteArrayInputStream(tmp.toByteArray()));
    ImageReader reader = ImageIO.getImageReaders(in).next();
    reader.setInput(in);

    // Retrieve standard image metadata tree
    IIOMetadata meta = reader.getImageMetadata(0);
    if (meta == null || !meta.isStandardMetadataFormatSupported()) {
        throw new Error("Test failure: Missing metadata");
    }
    Element root = (Element) meta.
            getAsTree(IIOMetadataFormatImpl.standardMetadataFormatName);

    // Test getElementsByTagName("*")
    if (root.getElementsByTagName("*").getLength() == 0) {
        throw new RuntimeException("getElementsByTagName(\"*\") returns"
                + " nothing");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:GetElementsByTagNameTest.java

示例3: convertMetadata

import javax.imageio.metadata.IIOMetadata; //导入方法依赖的package包/类
/**
 * Merges <code>inData</code> into <code>outData</code>. The supplied
 * metadata format name is attempted first and failing that the standard
 * metadata format name is attempted.
 */
private void convertMetadata(String metadataFormatName,
                             IIOMetadata inData,
                             IIOMetadata outData) {
    String formatName = null;

    String nativeFormatName = inData.getNativeMetadataFormatName();
    if (nativeFormatName != null &&
        nativeFormatName.equals(metadataFormatName)) {
        formatName = metadataFormatName;
    } else {
        String[] extraFormatNames = inData.getExtraMetadataFormatNames();

        if (extraFormatNames != null) {
            for (int i = 0; i < extraFormatNames.length; i++) {
                if (extraFormatNames[i].equals(metadataFormatName)) {
                    formatName = metadataFormatName;
                    break;
                }
            }
        }
    }

    if (formatName == null &&
        inData.isStandardMetadataFormatSupported()) {
        formatName = STANDARD_METADATA_NAME;
    }

    if (formatName != null) {
        try {
            Node root = inData.getAsTree(formatName);
            outData.mergeTree(formatName, root);
        } catch(IIOInvalidTreeException e) {
            // ignore
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:42,代码来源:GIFImageWriter.java

示例4: getMetadata

import javax.imageio.metadata.IIOMetadata; //导入方法依赖的package包/类
private IIOMetadata getMetadata(String formatName,
                                Set nodeNames,
                                boolean wantStream,
                                int imageIndex) throws IOException {
    if (formatName == null) {
        throw new IllegalArgumentException("formatName == null!");
    }
    if (nodeNames == null) {
        throw new IllegalArgumentException("nodeNames == null!");
    }
    IIOMetadata metadata =
        wantStream
        ? getStreamMetadata()
        : getImageMetadata(imageIndex);
    if (metadata != null) {
        if (metadata.isStandardMetadataFormatSupported() &&
            formatName.equals
            (IIOMetadataFormatImpl.standardMetadataFormatName)) {
            return metadata;
        }
        String nativeName = metadata.getNativeMetadataFormatName();
        if (nativeName != null && formatName.equals(nativeName)) {
            return metadata;
        }
        String[] extraNames = metadata.getExtraMetadataFormatNames();
        if (extraNames != null) {
            for (int i = 0; i < extraNames.length; i++) {
                if (formatName.equals(extraNames[i])) {
                    return metadata;
                }
            }
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:ImageReader.java

示例5: convertMetadata

import javax.imageio.metadata.IIOMetadata; //导入方法依赖的package包/类
/**
 * Merges {@code inData} into {@code outData}. The supplied
 * metadata format name is attempted first and failing that the standard
 * metadata format name is attempted.
 */
private void convertMetadata(String metadataFormatName,
                             IIOMetadata inData,
                             IIOMetadata outData) {
    String formatName = null;

    String nativeFormatName = inData.getNativeMetadataFormatName();
    if (nativeFormatName != null &&
        nativeFormatName.equals(metadataFormatName)) {
        formatName = metadataFormatName;
    } else {
        String[] extraFormatNames = inData.getExtraMetadataFormatNames();

        if (extraFormatNames != null) {
            for (int i = 0; i < extraFormatNames.length; i++) {
                if (extraFormatNames[i].equals(metadataFormatName)) {
                    formatName = metadataFormatName;
                    break;
                }
            }
        }
    }

    if (formatName == null &&
        inData.isStandardMetadataFormatSupported()) {
        formatName = STANDARD_METADATA_NAME;
    }

    if (formatName != null) {
        try {
            Node root = inData.getAsTree(formatName);
            outData.mergeTree(formatName, root);
        } catch(IIOInvalidTreeException e) {
            // ignore
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:42,代码来源:GIFImageWriter.java

示例6: getMetadata

import javax.imageio.metadata.IIOMetadata; //导入方法依赖的package包/类
private IIOMetadata getMetadata(String formatName,
                                Set<String> nodeNames,
                                boolean wantStream,
                                int imageIndex) throws IOException {
    if (formatName == null) {
        throw new IllegalArgumentException("formatName == null!");
    }
    if (nodeNames == null) {
        throw new IllegalArgumentException("nodeNames == null!");
    }
    IIOMetadata metadata =
        wantStream
        ? getStreamMetadata()
        : getImageMetadata(imageIndex);
    if (metadata != null) {
        if (metadata.isStandardMetadataFormatSupported() &&
            formatName.equals
            (IIOMetadataFormatImpl.standardMetadataFormatName)) {
            return metadata;
        }
        String nativeName = metadata.getNativeMetadataFormatName();
        if (nativeName != null && formatName.equals(nativeName)) {
            return metadata;
        }
        String[] extraNames = metadata.getExtraMetadataFormatNames();
        if (extraNames != null) {
            for (int i = 0; i < extraNames.length; i++) {
                if (formatName.equals(extraNames[i])) {
                    return metadata;
                }
            }
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:ImageReader.java

示例7: main

import javax.imageio.metadata.IIOMetadata; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    // Generate some trivial image and save it to a temporary array
    ByteArrayOutputStream tmp = new ByteArrayOutputStream();
    ImageIO.write(new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB),
            "gif", tmp);

    // Read it back in
    ImageInputStream in = new MemoryCacheImageInputStream(
            new ByteArrayInputStream(tmp.toByteArray()));
    ImageReader reader = ImageIO.getImageReaders(in).next();
    reader.setInput(in);

    // Retrieve standard image metadata tree
    IIOMetadata meta = reader.getImageMetadata(0);
    if (meta == null || !meta.isStandardMetadataFormatSupported()) {
        throw new Error("Test failure: Missing metadata");
    }
    Element root = (Element) meta.
            getAsTree(IIOMetadataFormatImpl.standardMetadataFormatName);

    NodeList nodeList = root.
            getElementsByTagName(root.getFirstChild().getNodeName());
    /*
     * Accessing the nth node should return null and not throw
     * IndexOutOfBoundsException.
     */
    Node n = (nodeList.item(nodeList.getLength()));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:NthItemNodeListTest.java

示例8: createFromMetadata

import javax.imageio.metadata.IIOMetadata; //导入方法依赖的package包/类
/**
 * Creates a {@code TIFFDirectory} instance from the contents of
 * an image metadata object. The supplied object must support an image
 * metadata format supported by the TIFF {@link javax.imageio.ImageWriter}
 * plug-in. This will usually be either the TIFF native image metadata
 * format {@code javax_imageio_tiff_image_1.0} or the Java
 * Image I/O standard metadata format {@code javax_imageio_1.0}.
 *
 * @param tiffImageMetadata A metadata object which supports a compatible
 * image metadata format.
 *
 * @return A {@code TIFFDirectory} populated from the contents of
 * the supplied metadata object.
 *
 * @throws NullPointerException if {@code tiffImageMetadata}
 * is {@code null}.
 * @throws IllegalArgumentException if {@code tiffImageMetadata}
 * does not support a compatible image metadata format.
 * @throws IIOInvalidTreeException if the supplied metadata object
 * cannot be parsed.
 */
public static TIFFDirectory
    createFromMetadata(IIOMetadata tiffImageMetadata)
    throws IIOInvalidTreeException {

    if(tiffImageMetadata == null) {
        throw new NullPointerException("tiffImageMetadata == null");
    }

    TIFFImageMetadata tim;
    if(tiffImageMetadata instanceof TIFFImageMetadata) {
        tim = (TIFFImageMetadata)tiffImageMetadata;
    } else {
        // Create a native metadata object.
        ArrayList<TIFFTagSet> l = new ArrayList<TIFFTagSet>(1);
        l.add(BaselineTIFFTagSet.getInstance());
        tim = new TIFFImageMetadata(l);

        // Determine the format name to use.
        String formatName = null;
        if(TIFFImageMetadata.NATIVE_METADATA_FORMAT_NAME.equals
           (tiffImageMetadata.getNativeMetadataFormatName())) {
            formatName = TIFFImageMetadata.NATIVE_METADATA_FORMAT_NAME;
        } else {
            String[] extraNames =
                tiffImageMetadata.getExtraMetadataFormatNames();
            if(extraNames != null) {
                for(int i = 0; i < extraNames.length; i++) {
                    if(TIFFImageMetadata.NATIVE_METADATA_FORMAT_NAME.equals
                       (extraNames[i])) {
                        formatName = extraNames[i];
                        break;
                    }
                }
            }

            if(formatName == null) {
                if(tiffImageMetadata.isStandardMetadataFormatSupported()) {
                    formatName =
                        IIOMetadataFormatImpl.standardMetadataFormatName;
                } else {
                    throw new IllegalArgumentException
                        ("Parameter does not support required metadata format!");
                }
            }
        }

        // Set the native metadata object from the tree.
        tim.setFromTree(formatName,
                        tiffImageMetadata.getAsTree(formatName));
    }

    return tim.getRootIFD();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:75,代码来源:TIFFDirectory.java


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