Java / JAI - save an image gray-scaled

后端 未结 2 1814
再見小時候
再見小時候 2021-01-19 15:59

I try to save the tiff instead of coloure gray-scaled. How could I do this? (JAI must be used, because it is a tiff!)

Thanks a lot in advance & Best Regards.

2条回答
  •  隐瞒了意图╮
    2021-01-19 16:13

    What you want is to download the JAI Image I/O Tools, which provides ImageIO adapters for JAI. Once you've installed that, it's smooth sailing.

    final BufferedImage in = ImageIO.read(new File("frabozzle.tif"));
    final BufferedImage out = new BufferedImage(
        in.getWidth(), in.getHeight(),
        BufferedImage.TYPE_BYTE_GRAY);
    out.getGraphics().drawImage(in, 0, 0, null);
    ImageIO.write(out, "TIFF", new File("graybozzle.tif"));
    

提交回复
热议问题