ImageIO.write TIFF返回false

时间:2018-01-10 17:00:41

标签: java tiff javax.imageio

我正在尝试使用ImageIO将BufferedImage写入TIFF文件,但它总是返回false。根据{{​​3}}:

  

如果找不到合适的编写器,则返回false。

写入PNG或JPG格式没有问题。我看到它可能与RGB与ARGB有关,但两种情况都不起作用。 “找不到合适的作家”是什么意思?任何帮助,将不胜感激! (使用v1.8.0_121)

        try
        {
            BufferedImage arbgBI = new BufferedImage(50, 50, BufferedImage.TYPE_INT_ARGB);
            System.err.println("PNG: " + ImageIO.write(arbgBI, "png", new File("arbgBI.png")));
            System.err.println("JPG: " + ImageIO.write(arbgBI, "jpg", new File("arbgBI.jpg")));
            System.err.println("TIFF: " + ImageIO.write(arbgBI, "tiff", new File("arbgBI.tiff")));

            BufferedImage rbgBI = new BufferedImage(50, 50, BufferedImage.TYPE_INT_RGB);
            System.err.println("PNG: " + ImageIO.write(rbgBI, "png", new File("rbgBI.png")));
            System.err.println("JPG: " + ImageIO.write(rbgBI, "jpg", new File("rbgBI.jpg")));
            System.err.println("TIFF: " + ImageIO.write(rbgBI, "tiff", new File("rbgBI.tiff")));                
        }
        catch (Exception ex) { System.err.println(ex); }

输出结果为:

PNG: true
JPG: true
TIFF: false
PNG: true
JPG: true
TIFF: false

0 个答案:

没有答案