Knight of the round table

wansong

tiff 显示

//jai_codec-1.1.3-alpha.jar

import java.awt.image.RenderedImage;
import java.io.File;

import com.sun.media.jai.codec.FileSeekableStream;
import com.sun.media.jai.codec.ImageCodec;
import com.sun.media.jai.codec.ImageDecoder;
import com.sun.media.jai.codec.SeekableStream;
import com.sun.media.jai.codec.TIFFDecodeParam;  

import javax.media.jai.JAI;

HttpServletRequest request = ServletActionContext.getRequest();
  HttpServletResponse response = ServletActionContext.getResponse();
  
  Integer index = new Integer(request.getParameter("index"));
  
  System.out.println(request.getContextPath());
  System.out.println(request.getPathInfo());
  System.out.println(request.getRealPath("/"));
  
        File file = new File(request.getRealPath("/") + "/example/tiff/example.tif");
        SeekableStream s = new FileSeekableStream(file);
        ImageDecoder dec = ImageCodec.createImageDecoder("tiff", s, null);
        RenderedImage temp = dec.decodeAsRenderedImage(index);
        System.out.println("Width:" + temp.getWidth() + ",Height:" + temp.getHeight());

JAI.create("encode", temp, response.getOutputStream(), "JPEG", null);
return null;

posted on 2011-01-12 20:23 w@ns0ng 阅读(290) 评论(0)  编辑  收藏 所属分类: J2EEjava


只有注册用户登录后才能发表评论。


网站导航: