【问题标题】:Save a BufferedImage as a TIFF file?将 BufferedImage 保存为 TIFF 文件?
【发布时间】:2012-05-09 07:16:51
【问题描述】:

以下代码可以很好地将BufferedImage 写入 .bmp、.jpg 和 .png 格式的文件:

import java.awt.*;
import javax.imageio.ImageIO;
...
BufferedImage image; // assume `image` is properly initialized
File file; // assume 'file' is properly initialized to some file
String format; // This is either 'bmp', 'jpg', or 'png'; if 'tif', it fails
ImageIO.write(imageBlank, format, file); // This properly creates a file for 'bmp', 'jpg', or 'png'; not for 'tif'

但是,当格式为 .tif 时,上述代码会在 write 行抛出异常。

许多链接建议使用 Java Advanced Imaging API 创建 TIFF;有些人提供以下链接:http://java.sun.com/javase/technologies/desktop/media/jai/。但是,此链接不会导致下载 JAI。其他链接要么是死的,要么是循环的。我不认为 JAI 包含在 JDK 1.7 中。我说的对吗?

有人可以提供实际 JAI 下载的工作链接,或者告诉我如何使用 JDK 1.7 从BufferedImage 创建一个 .tif 文件吗?

【问题讨论】:

    标签: java image tiff


    【解决方案1】:

    这个项目显然为 ImageIO 添加了 TIFF 读写功能:http://java.net/projects/imageio-ext

    如果您正在寻找 JAI 1.1.3:Where can I download Jai and Jai-imageio?

    【讨论】:

    【解决方案2】:
    猜你喜欢
    • 2012-09-22
    • 1970-01-01
    • 1970-01-01
    • 2011-10-07
    • 1970-01-01
    • 2021-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多