Java / JAI - save an image gray-scaled

…衆ロ難τιáo~ 提交于 2019-12-19 22:11:03

问题


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.


回答1:


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"));



回答2:


Given a BufferedImage, you can use the filter() method of ColorConvertOp, as shown in this example.



来源:https://stackoverflow.com/questions/2209766/java-jai-save-an-image-gray-scaled

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!