How to set icc color profile in Java and change colorspace

纵饮孤独 提交于 2019-12-18 13:54:33

问题


First, I would like to say I'm not an image processing specialist.

I would like to convert image colorspace from one to another, and change icc color profile at the same time. I managed to do it using JMagick (the ImageMagick Java port), but no way in pure Java (even using JAI).


回答1:


Use ColorConvertOp, this will do the color space conversion. You have several options to set a icc color profile. Either you use a predefined profile by using getInstance with the correct color space constant or you can specify a file, which contains a profile. Here is an example:

ICC_Profile ip = ICC_Profile.getInstance( ColorSpace.CS_sRGB );
ICC_ColorSpace ics = new ICC_ColorSpace( ip );
ColorConvertOp cco = new ColorConvertOp( ics, null );
BufferedImage result = cco.filter( sourceImage, null );

The result will contain an image with the sRGB color space.



来源:https://stackoverflow.com/questions/380678/how-to-set-icc-color-profile-in-java-and-change-colorspace

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