• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TIFFEncodeParam类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createSingleTiff

import com.sun.media.jai.codec.TIFFEncodeParam; //导入依赖的package包/类
public void createSingleTiff(File singleTifFile) {
    // jai approach
    try {
        OutputStream out = new FileOutputStream(singleTifFile);
        // ByteArrayOutputStream out = new ByteArrayOutputStream();
        TIFFEncodeParam param = new TIFFEncodeParam();

        Vector<RenderedImage> vector = new Vector<RenderedImage>();
        logger.debug("NbrOfImages {}", imageList.size());
        for (int i = 1; i < imageList.size(); i++) {
            vector.add(imageList.get(i));
        }
        param.setExtraImages(vector.iterator());

        ImageEncoder encoder = ImageCodec.createImageEncoder("TIFF", out,
                param);

        encoder.encode(imageList.get(0));
        // tempByteArray = out.toByteArray();
        out.close();
        logger.info("Single page tiff created");
    } catch (Exception e) {
        logger.error("Error creating single page tiff", e);
    }
}
 
开发者ID:xenit-eu,项目名称:move2alf,代码行数:26,代码来源:Tiff2Pdf.java


示例2: getEncoder

import com.sun.media.jai.codec.TIFFEncodeParam; //导入依赖的package包/类
@Override
protected ImageEncoder getEncoder(final RenderedImage image, final OutputStream out) {
  final TIFFEncodeParam param = new TIFFEncodeParam();
  return com.sun.media.jai.codec.ImageCodec.createImageEncoder("TIFF", out, param); //$NON-NLS-1$
}
 
开发者ID:AndreasWBartels,项目名称:libraries,代码行数:6,代码来源:TiffEncoder.java


示例3: makeImageSnapshot

import com.sun.media.jai.codec.TIFFEncodeParam; //导入依赖的package包/类
public void makeImageSnapshot() {
     if (((long) bimg.getWidth() * bimg.getHeight()) > (8000L * 8000L)) {
         JOptionPane.showMessageDialog(this, "In the current version this feature can only be used for images where width*height <= 8000*8000.\nHowever, you can use the Orbit Agent to download the file.", "Image too large", JOptionPane.ERROR_MESSAGE);
         return;
     }

     JFileChooser fc = new JFileChooser();
     FileNameExtensionFilter filter = new FileNameExtensionFilter("*.tif", "tif");
     fc.setFileFilter(filter);
     String snapShotFileName = getPicName();
     snapShotFileName = snapShotFileName.replaceAll(RawUtilsCommon.getExtension(snapShotFileName, false), "tif");
     fc.setSelectedFile(new File(snapShotFileName));

     int returnVal = fc.showSaveDialog(this);
     if (returnVal == JFileChooser.APPROVE_OPTION) {

         logger.debug("begin making image snapshot");
         String fn = fc.getSelectedFile().getAbsolutePath();
         if (!fn.toLowerCase().endsWith(".tif")) fn += ".tif";

         Dimension2D oldVPSize = viewPortSize;
         Point2D oldVPOffs = getViewPortOffset();
         double sc = getScale();
         setScale(100d);
         setViewPortOffset(new Point(0, 0));
         viewPortSize = new Dimension(bimg.getWidth(), bimg.getHeight());
		
/*
ColorModel colorModel = new ComponentColorModel(
		 ColorSpace.getInstance(ColorSpace.CS_sRGB),
		 new int[]{8,8,8}, false, false,
		 Transparency.OPAQUE, 
		 DataBuffer.TYPE_BYTE); 
SampleModel sampleModel = colorModel.createCompatibleSampleModel(256, 256);
DiskMemImage tiledImage = new DiskMemImage(0, 0, bimg.getWidth(), bimg.getHeight(), 0, 0, sampleModel, colorModel);
Graphics2D g2d = (Graphics2D)tiledImage.createGraphics();
((DiskMemImageGraphics)g2d).overwriteRenderingHint((((Graphics2D)getGraphics()).getRenderingHints()));
*/
         // Update 1.7.2010: Fallback to normal bufferedImage (only up to 30kx30k pixel!)
         // due to rendering problems with class image (only first tile problem)

         BufferedImage buffImg = new BufferedImage(bimg.getWidth(), bimg.getHeight(), BufferedImage.TYPE_INT_RGB);
         Graphics2D g2d = buffImg.createGraphics();
         buffImg.flush();


         paint(g2d);
         setScale(sc);
         setViewPortOffset(oldVPOffs);
         viewPortSize = oldVPSize;
         logger.info("finished painting");

         TIFFEncodeParam param = new TIFFEncodeParam();
         param.setTileSize(128, 128);
         param.setWriteTiled(true);
         param.setCompression(TIFFEncodeParam.COMPRESSION_JPEG_TTN2);
         JPEGEncodeParam jpgParam = new JPEGEncodeParam();
         jpgParam.setQuality(0.85f);
         param.setJPEGEncodeParam(jpgParam);

         // TODO: extraImages (Iterator where .next() returns further (low-res) RenderedImages
         //param.setExtraImages(extraImages)

         JAI.create("filestore", /*tiledImage*/buffImg, fn, "TIFF", param);

         logger.info("finished writing");

         JOptionPane.showMessageDialog(null, "Image successfully saved to " + fn, "Image saved", JOptionPane.INFORMATION_MESSAGE);

         //tiledImage = null;
         //DiskMemImage.getCommonTileCache().flush();
         Runtime.getRuntime().gc();
         Runtime.getRuntime().gc();
         Runtime.getRuntime().gc();
         logger.debug("cleaning up finished");

     }

 }
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:80,代码来源:RecognitionFrame.java


示例4: getSelectedTiffFile

import com.sun.media.jai.codec.TIFFEncodeParam; //导入依赖的package包/类
/**
 * The <code>getSelectedTiffFile</code> method is used to limit the file
 * to the page limit given.
 * 
 * @param tiffFile {@link File} tiff file from which limit has to be applied
 * @param pageLimit int
 * @throws IOException if file is not found
 */
public static void getSelectedTiffFile(final File tiffFile, final int pageLimit) throws IOException {
	OutputStream out = null;
	File newTiffFile = null;
	if (null != tiffFile && getTIFFPageCount(tiffFile.getAbsolutePath()) > pageLimit) {
		try {
			final List<BufferedImage> imageList = new ArrayList<BufferedImage>();
			final SeekableStream seekableStream = new FileSeekableStream(tiffFile);
			final ImageDecoder decoder = ImageCodec.createImageDecoder("tiff", seekableStream, null);
			for (int i = 1; i < pageLimit; i++) {
				final PlanarImage planarImage = new NullOpImage(decoder.decodeAsRenderedImage(i), null, null, OpImage.OP_IO_BOUND);
				imageList.add(planarImage.getAsBufferedImage());
			}
			seekableStream.close();
			final TIFFEncodeParam params = new TIFFEncodeParam();
			params.setCompression(TIFFEncodeParam.COMPRESSION_GROUP4);
			String name = tiffFile.getName();
			final int indexOf = name.lastIndexOf(IUtilCommonConstants.DOT);
			name = name.substring(0, indexOf);
			final String finalPath = tiffFile.getParent() + File.separator + name
					+ System.currentTimeMillis() + IUtilCommonConstants.EXTENSION_TIF;
			newTiffFile = new File(finalPath);
			out = new FileOutputStream(finalPath); 
			final ImageEncoder encoder = ImageCodec.createImageEncoder("tiff", out, params);
            params.setExtraImages(imageList.iterator()); 
            encoder.encode(imageList.get(0));
		} finally {
			if (null != out) {
				out.flush();
				out.close();
			}
		}
           if (tiffFile.delete() && null != newTiffFile) {
           	newTiffFile.renameTo(tiffFile);
		} else {
			if (null != newTiffFile) {
				newTiffFile.delete();
			}
		}
	}
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:49,代码来源:TIFFUtil.java


示例5: saveTiff

import com.sun.media.jai.codec.TIFFEncodeParam; //导入依赖的package包/类
public static void saveTiff(final File[] files, File tiffFile)
		throws IOException
{

	class Temp implements Iterator
	{
		File[] images;

		int last = 0;

		public Temp(File[] file)
		{
			this.images = file;
		}

		@Override
		public boolean hasNext()
		{
			// TODO Auto-generated method stub
			return last < images.length;
		}

		@Override
		public Object next()
		{
			try
			{
				BufferedImage img = ImageIO.read(images[last++]);
				return ImageOperations.cropImage(img, new Rectangle(0, 0,
						img.getWidth(), 200));
			} catch (IOException e)
			{
				// TODO Auto-generated catch
				// block
				e.printStackTrace();
			}
			return null;
		}

		@Override
		public void remove()
		{
			// TODO Auto-generated method stub

		}
	}

	Temp fileHolder = new Temp(files);

	TIFFEncodeParam param = new TIFFEncodeParam();
	param.setExtraImages(fileHolder);
	param.setCompression(TIFFEncodeParam.COMPRESSION_NONE);

	ParameterBlock pb = new ParameterBlock();
	OutputStream os = new FileOutputStream(tiffFile);

	pb.addSource(fileHolder.next());
	// pb.addSource ( JAI.create ( "fileload",
	// filename ) ) ;
	pb.add(os);
	pb.add("TIFF");
	pb.add(param);
	JAI.create("encode", pb);
	os.close();

}
 
开发者ID:TOMIGalway,项目名称:cmoct-sourcecode,代码行数:67,代码来源:ReactiveHyperimeaTool.java


示例6: convertPdfToImage

import com.sun.media.jai.codec.TIFFEncodeParam; //导入依赖的package包/类
public static void convertPdfToImage(File file, String createPath, int type)
		throws Exception {
	@SuppressWarnings("resource")
	FileChannel channel = new RandomAccessFile(file, "r").getChannel();
	MappedByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0,
			channel.size());
	PDFFile pdffile = new PDFFile(buf);

	for (int i = 1; i <= pdffile.getNumPages(); i++) {
		PDFPage page = pdffile.getPage(i);
		Rectangle rect = new Rectangle(0, 0, (int) page.getBBox()
				.getWidth(), (int) page.getBBox().getHeight());
		Image img = page.getImage(rect.width, rect.height, rect, null,
				true, true);

		BufferedImage tag = new BufferedImage(rect.width, rect.height,
				BufferedImage.TYPE_INT_RGB);
		tag.getGraphics().drawImage(img, 0, 0, rect.width, rect.height,
				null);

		String fileName = createPath
				+ "\\"
				+ file.getName().substring(0,
						file.getName().lastIndexOf('.'));
		FileOutputStream out = null;
		ImageEncoder enc = null;
		switch (type) {
		case ImageType.TYPE_JPEG:
			out = new FileOutputStream(fileName + i + ".jpg");
			enc = ImageCodec.createImageEncoder("jpeg", out,
					new JPEGEncodeParam());
			break;
		case ImageType.TYPE_TIFF:
			out = new FileOutputStream(fileName + i + ".tif");
			enc = ImageCodec.createImageEncoder("tiff", out,
					new TIFFEncodeParam());
			break;
		}
		if (null != out && null != enc) {
			enc.encode(tag);
			out.close();
		}

	}
}
 
开发者ID:joaquinaimar,项目名称:wizard,代码行数:46,代码来源:ImageCodeUtil.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StringCache类代码示例发布时间:2022-05-23
下一篇:
Java BoundingBox类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap