本文整理匯總了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);
}
}
}