如何在Java 10中读取TIFF文件?

时间:2018-07-02 14:06:18

标签: tiff java-10

我只是尝试做:

File inputFile = new File("image.tif");
BufferedImage image = ImageIO.read(inputFile);

因为我认为Java 10不需要额外的库来处理tiff文件,但BufferedImage为null。

1 个答案:

答案 0 :(得分:-1)

自JDK 9起,这应该可行:

private Image readTiffImage() throws IOException
{

final InputStream tiffImage = TiffExample.class.getResourceAsStream("image.tiff");

final BufferedImage bufferedImage = ImageIO.read(tiffImage);
final Image image = SwingFXUtils.toFXImage(bufferedImage, null);
return image;
}