本文整理汇总了Java中javax.imageio.metadata.IIOMetadata.getMetadataFormatNames方法的典型用法代码示例。如果您正苦于以下问题:Java IIOMetadata.getMetadataFormatNames方法的具体用法?Java IIOMetadata.getMetadataFormatNames怎么用?Java IIOMetadata.getMetadataFormatNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.imageio.metadata.IIOMetadata
的用法示例。
在下文中一共展示了IIOMetadata.getMetadataFormatNames方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import javax.imageio.metadata.IIOMetadata; //导入方法依赖的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");
}
}
示例2: doTest
import javax.imageio.metadata.IIOMetadata; //导入方法依赖的package包/类
public void doTest() throws IOException {
DummyImageReaderImpl reader;
reader = new DummyImageReaderImpl(new DummyImageReaderSpiImpl());
byte[] data = new byte[1024];
ByteArrayInputStream bais =
new ByteArrayInputStream(data);
reader.setInput(ImageIO.createImageInputStream(bais));
IIOMetadata metadata = reader.getImageMetadata(1);
if(metadata == null) {
throw new RuntimeException("IIOMetada is NULL");
}
String[] formatNames = metadata.getMetadataFormatNames();
for(int j=0; j<formatNames.length; j++) {
String formatName = formatNames[j];
System.out.println("\nFormat Names : " + formatName);
try {
IIOMetadataFormat metadataFormat =
metadata.getMetadataFormat(formatName);
System.out.println(" Class Name " +
metadataFormat.getClass());
} catch(IllegalStateException ise) {
Throwable t = ise;
t.printStackTrace();
while(t.getCause() != null) {
t = t.getCause();
t.printStackTrace();
}
// test failed!
// stop applet!
System.out.println("Test faied.");
throw new RuntimeException("Test failed.", ise);
}
}
}