本文整理汇总了Java中javax.imageio.ImageIO.getImageReadersBySuffix方法的典型用法代码示例。如果您正苦于以下问题:Java ImageIO.getImageReadersBySuffix方法的具体用法?Java ImageIO.getImageReadersBySuffix怎么用?Java ImageIO.getImageReadersBySuffix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.imageio.ImageIO
的用法示例。
在下文中一共展示了ImageIO.getImageReadersBySuffix方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetReaderFileSuffixes
import javax.imageio.ImageIO; //导入方法依赖的package包/类
private static void testGetReaderFileSuffixes() {
String[] suffixes = ImageIO.getReaderFileSuffixes();
for (String s : suffixes) {
Iterator<ImageReader> it = ImageIO.getImageReadersBySuffix(s);
if (!it.hasNext()) {
throw new RuntimeException("getReaderFileSuffixes returned " +
"an unknown suffix: " + s);
}
}
}
示例2: main
import javax.imageio.ImageIO; //导入方法依赖的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.");
}
}
示例3: testReaderIsRegistered
import javax.imageio.ImageIO; //导入方法依赖的package包/类
@Test
public void testReaderIsRegistered() {
Supplier<Iterator<ImageReader>> getReaderIter = () -> ImageIO.getImageReadersBySuffix("jpg");
assertThat(getReaderIter.get()).isNotEmpty();
assertThat(getReaderIter.get()).hasAtLeastOneElementOfType(TurboJpegImageReader.class);
getReaderIter = () -> ImageIO.getImageReadersByMIMEType("image/jpeg");
assertThat(getReaderIter.get()).isNotEmpty();
assertThat(getReaderIter.get()).hasAtLeastOneElementOfType(TurboJpegImageReader.class);
getReaderIter = () -> ImageIO.getImageReadersByFormatName("jpeg");
assertThat(getReaderIter.get()).isNotEmpty();
assertThat(getReaderIter.get()).hasAtLeastOneElementOfType(TurboJpegImageReader.class);
}