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


Java ImageIO.getImageReadersByMIMEType方法代码示例

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


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

示例1: chooseImageFormat

import javax.imageio.ImageIO; //导入方法依赖的package包/类
public static String chooseImageFormat(String[] formats) {
	 if (formats == null || formats.length == 0)
		return null;
	for (String s : formatOrderPreference) {
		for (String f : formats) {
			if (f.equalsIgnoreCase(s)) {
				Iterator it = ImageIO.getImageReadersByMIMEType(f); 
				if (it.hasNext())
						return f;
			}
		}
	}

	System.err.println("No image recoginized, using " + formats[0]); 

	return formats[0]; // none recognized; just use the first in the caps list
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:18,代码来源:LayerExplorer.java

示例2: isReadable

import javax.imageio.ImageIO; //导入方法依赖的package包/类
private boolean isReadable(MediaType mediaType) {
	if (mediaType == null) {
		return true;
	}
	Iterator<ImageReader> imageReaders = ImageIO.getImageReadersByMIMEType(mediaType.toString());
	return imageReaders.hasNext();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:BufferedImageHttpMessageConverter.java

示例3: read

import javax.imageio.ImageIO; //导入方法依赖的package包/类
@Override
public BufferedImage read(Class<? extends BufferedImage> clazz, HttpInputMessage inputMessage)
		throws IOException, HttpMessageNotReadableException {

	ImageInputStream imageInputStream = null;
	ImageReader imageReader = null;
	try {
		imageInputStream = createImageInputStream(inputMessage.getBody());
		MediaType contentType = inputMessage.getHeaders().getContentType();
		Iterator<ImageReader> imageReaders = ImageIO.getImageReadersByMIMEType(contentType.toString());
		if (imageReaders.hasNext()) {
			imageReader = imageReaders.next();
			ImageReadParam irp = imageReader.getDefaultReadParam();
			process(irp);
			imageReader.setInput(imageInputStream, true);
			return imageReader.read(0, irp);
		}
		else {
			throw new HttpMessageNotReadableException(
					"Could not find javax.imageio.ImageReader for Content-Type [" + contentType + "]");
		}
	}
	finally {
		if (imageReader != null) {
			imageReader.dispose();
		}
		if (imageInputStream != null) {
			try {
				imageInputStream.close();
			}
			catch (IOException ex) {
				// ignore
			}
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:BufferedImageHttpMessageConverter.java

示例4: testGetReaderMIMETypes

import javax.imageio.ImageIO; //导入方法依赖的package包/类
private static void testGetReaderMIMETypes() {
    String[] types = ImageIO.getReaderMIMETypes();
    for (String t : types) {
        Iterator<ImageReader> it = ImageIO.getImageReadersByMIMEType(t);
        if (!it.hasNext()) {
            throw new RuntimeException("getReaderMIMETypes returned " +
                                       "an unknown type: " + t);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:GetReaderWriterInfo.java

示例5: 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);
}
 
开发者ID:dbmdz,项目名称:imageio-jnr,代码行数:13,代码来源:TurboJpegImageReaderTest.java


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