當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。