本文整理匯總了Java中javax.imageio.spi.ImageReaderSpi.getImageMetadataFormat方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageReaderSpi.getImageMetadataFormat方法的具體用法?Java ImageReaderSpi.getImageMetadataFormat怎麽用?Java ImageReaderSpi.getImageMetadataFormat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.imageio.spi.ImageReaderSpi
的用法示例。
在下文中一共展示了ImageReaderSpi.getImageMetadataFormat方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import javax.imageio.spi.ImageReaderSpi; //導入方法依賴的package包/類
public static void main(String args[]) throws Exception {
Iterator<ImageReader> readers = ImageIO.getImageReadersBySuffix("simp");
ImageReader simpReader = null;
if (readers.hasNext()) {
simpReader = readers.next();
System.out.println("reader="+simpReader);
}
if (simpReader == null) {
throw new RuntimeException("Reader not found.");
}
ImageReaderSpi spi = simpReader.getOriginatingProvider();
IIOMetadataFormat spiFmt =
spi.getImageMetadataFormat("simp_metadata_1.0");
System.out.println("fmt from SPI=" + spiFmt);
ByteArrayInputStream bais = new ByteArrayInputStream(simpData);
ImageInputStream iis = new MemoryCacheImageInputStream(bais);
simpReader.setInput(iis);
BufferedImage bi = simpReader.read(0);
System.out.println(bi);
IIOMetadata metadata = simpReader.getImageMetadata(0);
System.out.println("Image metadata="+metadata);
IIOMetadataFormat format =
metadata.getMetadataFormat("simp_metadata_1.0");
System.out.println("Image metadata format="+format);
if (format == null) {
throw new RuntimeException("MetadataFormat not found.");
}
}
示例2: main
import javax.imageio.spi.ImageReaderSpi; //導入方法依賴的package包/類
public static void main(String[] args) {
IIOMetadataFormat format = null;
if (args.length == 0 || args[0].equals("javax_imageio_1.0")) {
format = IIOMetadataFormatImpl.getStandardFormatInstance();
} else {
IIORegistry registry = IIORegistry.getDefaultInstance();
Iterator iter = registry.getServiceProviders(ImageReaderSpi.class,
false);
while (iter.hasNext()) {
ImageReaderSpi spi = (ImageReaderSpi)iter.next();
if (args[0].equals
(spi.getNativeStreamMetadataFormatName())) {
System.out.print(spi.getDescription(null));
System.out.println(": native stream format");
format = spi.getStreamMetadataFormat(args[0]);
break;
}
String[] extraStreamFormatNames =
spi.getExtraStreamMetadataFormatNames();
if (extraStreamFormatNames != null &&
Arrays.asList(extraStreamFormatNames).
contains(args[0])) {
System.out.print(spi.getDescription(null));
System.out.println(": extra stream format");
format = spi.getStreamMetadataFormat(args[0]);
break;
}
if (args[0].equals
(spi.getNativeImageMetadataFormatName())) {
System.out.print(spi.getDescription(null));
System.out.println(": native image format");
format = spi.getImageMetadataFormat(args[0]);
break;
}
String[] extraImageFormatNames =
spi.getExtraImageMetadataFormatNames();
if (extraImageFormatNames != null &&
Arrays.asList(extraImageFormatNames).contains(args[0])) {
System.out.print(spi.getDescription(null));
System.out.println(": extra image format");
format = spi.getImageMetadataFormat(args[0]);
break;
}
}
}
if (format == null) {
System.err.println("Unknown format: " + args[0]);
System.exit(0);
}
MetadataFormatPrinter printer = new MetadataFormatPrinter(System.out);
printer.print(format);
}