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


Java TIFFDecodeParam类代码示例

本文整理汇总了Java中com.sun.media.jai.codec.TIFFDecodeParam的典型用法代码示例。如果您正苦于以下问题:Java TIFFDecodeParam类的具体用法?Java TIFFDecodeParam怎么用?Java TIFFDecodeParam使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TIFFDecodeParam类属于com.sun.media.jai.codec包,在下文中一共展示了TIFFDecodeParam类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: privateReadFromFile

import com.sun.media.jai.codec.TIFFDecodeParam; //导入依赖的package包/类
private BufferedImage privateReadFromFile(final File file) throws IOException {
	// System.out.println("READING " + file.getName());
	BufferedImage result = NO_IMAGE;
	if (file == null)
		return result;
	final String name = file.getName();
	String ext = null;
	if (name.contains(".")) {
		ext = name.substring(file.getName().lastIndexOf("."));
	}
	if (tiffExt.contains(ext)) {
		try (FileSeekableStream stream = new FileSeekableStream(file.getAbsolutePath())) {
			final TIFFDecodeParam decodeParam = new TIFFDecodeParam();
			decodeParam.setDecodePaletteAsShorts(true);
			final ParameterBlock params = new ParameterBlock();
			params.add(stream);
			final RenderedOp image1 = JAI.create("tiff", params);
			return image1.getAsBufferedImage();
		}
	} else if (gifExt.contains(ext)) {
		final GifDecoder d = new GifDecoder();
		d.read(new FileInputStream(file.getAbsolutePath()));
		return d.getImage();
	}

	try {
		result = ImageIO.read(file);
	} catch (final Exception e) {
		return NO_IMAGE;
	}
	return result;
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:33,代码来源:ImageUtils.java

示例2: openTIFF

import com.sun.media.jai.codec.TIFFDecodeParam; //导入依赖的package包/类
static private final BufferedImage openTIFF(final String path) throws Exception {
	/*
	final RenderedImage ri = ImageCodec.createImageDecoder("TIFF", new File(path), new TIFFDecodeParam()).decodeAsRenderedImage();
	final PlanarImage pi = PlanarImage.wrapRenderedImage(ri);
	final BufferedImage img = pi.getAsBufferedImage();
	*/
	return PlanarImage.wrapRenderedImage(ImageCodec.createImageDecoder("TIFF", new File(path), new TIFFDecodeParam()).decodeAsRenderedImage()).getAsBufferedImage();
}
 
开发者ID:trakem2,项目名称:TrakEM2,代码行数:9,代码来源:ImageSaver.java

示例3: convertTiff

import com.sun.media.jai.codec.TIFFDecodeParam; //导入依赖的package包/类
private void convertTiff(ByteArrayOutputStream outputStream, ByteArrayInputStream inStream) throws IOException, DocumentException, BadElementException, MalformedURLException 
{
	TIFFDecodeParam param = null;
	ImageDecoder decoder = ImageCodec.createImageDecoder("tiff", inStream, param);	
	System.out.println("Convert TIFF file: Found " + decoder.getNumPages() + " pages");
	
	ArrayList<ByteArrayOutputStream> imagesStream = new ArrayList<ByteArrayOutputStream>();
	
	int pages = decoder.getNumPages();
	for (int i = 0; i < pages; i++) 
	{
		RenderedImage render = decoder.decodeAsRenderedImage(i);
		PlanarImage op = new NullOpImage(render, null, null, OpImage.OP_IO_BOUND);
		BufferedImage imageBuffer = op.getAsBufferedImage();
		
		ByteArrayOutputStream os = new ByteArrayOutputStream();
		ImageIO.write(imageBuffer, "jpg", os);
		
		imagesStream.add(os);
	}
	
	if (imagesStream.size() > 0)
	{						
		Document document = new Document(PageSize.A4.rotate());
		PdfWriter writer = PdfWriter.getInstance(document, outputStream);
		
		document.open();
		
		Iterator<ByteArrayOutputStream> iterator = imagesStream.iterator();
		while (iterator.hasNext()) 
	    {
			document.newPage();
			Image jpg = Image.getInstance(iterator.next().toByteArray());
			jpg.scaleAbsolute(document.getPageSize().getWidth(), document.getPageSize().getHeight());
			document.add(jpg);
			
		}
		
		document.close();
		writer.flush();
		writer.close();
	}
}
 
开发者ID:IMS-MAXIMS,项目名称:openMAXIMS,代码行数:44,代码来源:ConversionHelper.java


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