since.2006  

 转换tif文件为图像文件可以使用JAI,jimi等包来处理

jimi处理一份39页的tif文件生成png并缩小,使用14秒。
JAI处理同一份文件却用了近60秒。(因该是偶技术问题造成的):-)

jimi处理的主要源码:

JimiCanvas jCanvas = new JimiCanvas();    
jCanvas.setImagePath(filepath);    
// 这里得到的就是tiff文件中第一页普通的Image对象了    
Image image = jCanvas.getImage();    
// 在这个文件中生成缩略图    
   
process(image);    
// 如果多于一页,循环取出    
while (jCanvas.hasNextImage()) {    
    jCanvas.nextImage();    
    image = jCanvas.getImage();    
    process(image);    
}    
   
public static void process(Image image) {    
    double width = (double) image.getWidth(null);    
    double height = (double) image.getHeight(null);    
    // 宽,高各缩小一半    
    int iWidth = (int) (width * 0.5);    
    int iHeight = (int) (height * 0.5);    
    // 用像生成其它图像文件一样的方式生成缩略图    
    BufferedImage bi = new BufferedImage(iWidth, iHeight, BufferedImage.TYPE_INT_RGB);    
    bi.getGraphics().drawImage(image, 0, 0, iWidth, iHeight, null);    
    // 输出BufferedImage    
}  
标签:

Posted by hee at 14:01 PM | Permalink | 评论(0) | Java

请输入名称
请输入邮件地址

 

    请输入邮件地址