
/* Do nothing, just to understand ICC in Java */
/* Author: Luciano P Soares, lpsoares@immi.inesc-id.pt */

import java.awt.color.ICC_ColorSpace;
import java.awt.color.ICC_Profile;
import java.awt.color.ICC_ProfileRGB;
import java.io.IOException;

public class TestICC {
 
    public static void main(String[] args) throws IOException {
        
        ICC_ProfileRGB RGB =
        	(ICC_ProfileRGB)ICC_ProfileRGB.getInstance("c:\\s.icm");
        
        ICC_ColorSpace col = new ICC_ColorSpace(RGB);
        RGB = (ICC_ProfileRGB)col.getProfile();
        
        System.out.println("Man Str : " + RGB.toString() );
                
        System.out.println("MinorVersion " + RGB.getMinorVersion()+ " - " + RGB.getMajorVersion() );        

        System.out.println(" X " + ICC_Profile.icXYZNumberX );
        System.out.println(" V " + ICC_Profile.icHdrVersion );
        System.out.println(" CMM " + ICC_Profile.icHdrCmmId );
        
        System.out.println(" Manuf " + ICC_Profile.icHdrManufacturer );
        System.out.println(" Ilum " + ICC_Profile.icHdrIlluminant );
        
        System.out.println("Man Str : " + (RGB.getData(ICC_Profile.icHdrManufacturer)) );
        System.out.println("Man 4 : " + (RGB.getData(4)) );
        
        float wpoint[] = RGB.getMediaWhitePoint();
        System.out.println("MediaWhitePoint = " + 
        		wpoint[0] + " , " + wpoint[1] + " , " + wpoint[2]);    
        
        short trc[];
        trc = RGB.getTRC(ICC_ProfileRGB.REDCOMPONENT);
        System.out.println("TRC = " + 
        		trc[0] + " , " + trc[1] + " , " + trc[2] + " , " + trc[3]+ " , " + trc[4]);

        trc = RGB.getTRC(ICC_ProfileRGB.GREENCOMPONENT);
        System.out.println("TRC = " + 
        		trc[0] + " , " + trc[1] + " , " + trc[2] + " , " + trc[3]+ " , " + trc[4]);

        trc = RGB.getTRC(ICC_ProfileRGB.BLUECOMPONENT);
        System.out.println("TRC = " + 
        		trc[0] + " , " + trc[1] + " , " + trc[2] + " , " + trc[3]+ " , " + trc[4]);

        System.out.println("Red : " + ICC_ProfileRGB.REDCOMPONENT);
        System.out.println("Green : " + ICC_ProfileRGB.GREENCOMPONENT);
        System.out.println("Blue : " + ICC_ProfileRGB.BLUECOMPONENT);
        
        float matrix[][] = RGB.getMatrix();
        System.out.println("Matrix = ");
        System.out.println( matrix[0][0] + " , " + matrix[0][1] + " , " + matrix[0][2]);
        System.out.println( matrix[1][0] + " , " + matrix[1][1] + " , " + matrix[1][2]);
        System.out.println( matrix[2][0] + " , " + matrix[2][1] + " , " + matrix[2][2]);
        
        //float ga = RGB.getGamma(0);
        //System.out.println("Gamma : " + ga);
        
        RGB.write("c:\\test.icm"); 

    }
}
