Packages

 

com.aspose.imaging

Interfaces

Classes

Exceptions

com.aspose.imaging

Class CmykColorHelper



  • public final class CmykColorHelper
    extends Object

    Helper methods to work with CMYK color presented as a signed 32-bit integer value. Provides the similar API as the com.aspose.imaging.CmykColor struct. It's more lightweight because CMYK color is presented just as Int32 rather than structure with internal fields. Please prefer to use static methods of this class when possible instead of the deprecated com.aspose.imaging.CmykColor struct.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static int fromComponents(int cyan, int magenta, int yellow, int black)
      Creates CMYK from a 32-bit cyan, magenta, yellow and black values.
      static int getC(int cmyk)
      Gets the cyan component value.
      static int getK(int cmyk)
      Gets the black component value.
      static int getM(int cmyk)
      Gets the magenta component value.
      static int getY(int cmyk)
      Gets the yellow component value.
      static Color toArgb(int cmykPixel)
      The conversion from CMYK color to ARGB color.
      static Color[] toArgb(int[] cmykPixels)
      The conversion from CMYK colors to ARGB colors.
      static int[] toArgb32(int[] cmykPixels)
      The conversion from CMYK colors to ARGB colors.
      static Color toArgbIcc(int cmykPixel)
      The conversion from CMYK color to ARGB Color using Icc conversion with default profiles.
      static Color[] toArgbIcc(int[] cmykPixels)
      The conversion from CMYK colors to ARGB colors using Icc conversion with default profiles.
      static Color[] toArgbIcc(int[] cmykPixels, InputStream cmykIccStream, InputStream rgbIccStream)
      The conversion from CMYK colors to ARGB colors using Icc conversion with custom profiles.
      static Color toArgbIcc(int cmykPixel, InputStream cmykIccStream, InputStream rgbIccStream)
      The conversion from CMYK color to ARGB color using Icc conversion with custom profile.
      static int toCmyk(Color pixel)
      The conversion from ARGB color to CMYK color.
      static int[] toCmyk(Color[] pixels)
      The conversion from ARGB colors to CMYK colors.
      static int toCmyk(int argbPixel)
      The conversion from ARGB color to CMYK color.
      static int[] toCmyk(int[] argbPixels)
      The conversion from ARGB colors to CMYK colors.
      static byte[] toCmykBytes(int[] argbPixels, int startIndex, int length)
      Converts RGB to CMYK.
      static int toCmykIcc(Color pixel)
      The conversion from ARGB color to CMYK color using Icc conversion with default profiles.
      static int[] toCmykIcc(Color[] pixels)
      The conversion from ARGB colors to CMYK colors using Icc conversion with default profiles.
      static int[] toCmykIcc(Color[] pixels, InputStream rgbIccStream, InputStream cmykIccStream)
      The conversion from ARGB colors to CMYK colors using Icc conversion with custom profiles.
      static int toCmykIcc(Color pixel, InputStream rgbIccStream, InputStream cmykIccStream)
      The conversion from ARGB color to CMYK color using Icc conversion with custom profiles.
      static byte[] toCmykIccBytes(int[] pixels, int startIndex, int length, InputStream rgbIccStream, InputStream cmykIccStream)
      Converts RGB to CMYK using custom ICC profiles.
    • Method Detail

      • getC

        public static int getC(int cmyk)

        Gets the cyan component value.

        Parameters:
        cmyk - The CMYK color presented as a 32-bit integer value.
        Returns:
        The cyan component value.
        Code example:

        The following example shows how to convert RGB colors to their CMYK counterparts without applying ICC profiles.


        com.aspose.imaging.Color[] rgbColors = new com.aspose.imaging.Color[]
                {
                        com.aspose.imaging.Color.getRed(),
                        com.aspose.imaging.Color.getGreen(),
                        com.aspose.imaging.Color.getBlue(),
                };
        
        System.out.println("Convert RGB to CMYK without using ICC profiles.");
        for (com.aspose.imaging.Color rgbColor : rgbColors) {
            int cmyk = com.aspose.imaging.CmykColorHelper.toCmyk(rgbColor);
            int c = com.aspose.imaging.CmykColorHelper.getC(cmyk);
            int m = com.aspose.imaging.CmykColorHelper.getM(cmyk);
            int y = com.aspose.imaging.CmykColorHelper.getY(cmyk);
            int k = com.aspose.imaging.CmykColorHelper.getK(cmyk);
        
            System.out.printf("RGB(@%s,%s,%s)\t\t=> CMYK(%s,%s,%s,%s)\r\n", rgbColor.getR() & 0xff, rgbColor.getG() & 0xff, rgbColor.getB() & 0xff, c, m, y, k);
        }
        
        //The output looks like this:
        //Convert RGB to CMYK without using ICC profiles.
        //RGB(255,0,0)        => CMYK(0,255,255,0)
        //RGB(0,128,0)        => CMYK(255,0,255,127)
        //RGB(0,0,255)        => CMYK(255,255,0,0)
        

      • getM

        public static int getM(int cmyk)

        Gets the magenta component value.

        Parameters:
        cmyk - The CMYK color presented as a 32-bit integer value.
        Returns:
        The magenta component value.
        Code example:

        The following example shows how to convert RGB colors to their CMYK counterparts without applying ICC profiles.


        com.aspose.imaging.Color[] rgbColors = new com.aspose.imaging.Color[]
                {
                        com.aspose.imaging.Color.getRed(),
                        com.aspose.imaging.Color.getGreen(),
                        com.aspose.imaging.Color.getBlue(),
                };
        
        System.out.println("Convert RGB to CMYK without using ICC profiles.");
        for (com.aspose.imaging.Color rgbColor : rgbColors) {
            int cmyk = com.aspose.imaging.CmykColorHelper.toCmyk(rgbColor);
            int c = com.aspose.imaging.CmykColorHelper.getC(cmyk);
            int m = com.aspose.imaging.CmykColorHelper.getM(cmyk);
            int y = com.aspose.imaging.CmykColorHelper.getY(cmyk);
            int k = com.aspose.imaging.CmykColorHelper.getK(cmyk);
        
            System.out.printf("RGB(@%s,%s,%s)\t\t=> CMYK(%s,%s,%s,%s)\r\n", rgbColor.getR() & 0xff, rgbColor.getG() & 0xff, rgbColor.getB() & 0xff, c, m, y, k);
        }
        
        //The output looks like this:
        //Convert RGB to CMYK without using ICC profiles.
        //RGB(255,0,0)        => CMYK(0,255,255,0)
        //RGB(0,128,0)        => CMYK(255,0,255,127)
        //RGB(0,0,255)        => CMYK(255,255,0,0)
        

      • getY

        public static int getY(int cmyk)

        Gets the yellow component value.

        Parameters:
        cmyk - The CMYK color presented as a 32-bit integer value.
        Returns:
        The yellow component value.
        Code example:

        The following example shows how to convert RGB colors to their CMYK counterparts without applying ICC profiles.


        com.aspose.imaging.Color[] rgbColors = new com.aspose.imaging.Color[]
                {
                        com.aspose.imaging.Color.getRed(),
                        com.aspose.imaging.Color.getGreen(),
                        com.aspose.imaging.Color.getBlue(),
                };
        
        System.out.println("Convert RGB to CMYK without using ICC profiles.");
        for (com.aspose.imaging.Color rgbColor : rgbColors) {
            int cmyk = com.aspose.imaging.CmykColorHelper.toCmyk(rgbColor);
            int c = com.aspose.imaging.CmykColorHelper.getC(cmyk);
            int m = com.aspose.imaging.CmykColorHelper.getM(cmyk);
            int y = com.aspose.imaging.CmykColorHelper.getY(cmyk);
            int k = com.aspose.imaging.CmykColorHelper.getK(cmyk);
        
            System.out.printf("RGB(@%s,%s,%s)\t\t=> CMYK(%s,%s,%s,%s)\r\n", rgbColor.getR() & 0xff, rgbColor.getG() & 0xff, rgbColor.getB() & 0xff, c, m, y, k);
        }
        
        //The output looks like this:
        //Convert RGB to CMYK without using ICC profiles.
        //RGB(255,0,0)        => CMYK(0,255,255,0)
        //RGB(0,128,0)        => CMYK(255,0,255,127)
        //RGB(0,0,255)        => CMYK(255,255,0,0)
        

      • getK

        public static int getK(int cmyk)

        Gets the black component value.

        Parameters:
        cmyk - The CMYK color presented as a 32-bit integer value.
        Returns:
        The black component value.
        Code example:

        The following example shows how to convert RGB colors to their CMYK counterparts without applying ICC profiles.


        com.aspose.imaging.Color[] rgbColors = new com.aspose.imaging.Color[]
                {
                        com.aspose.imaging.Color.getRed(),
                        com.aspose.imaging.Color.getGreen(),
                        com.aspose.imaging.Color.getBlue(),
                };
        
        System.out.println("Convert RGB to CMYK without using ICC profiles.");
        for (com.aspose.imaging.Color rgbColor : rgbColors) {
            int cmyk = com.aspose.imaging.CmykColorHelper.toCmyk(rgbColor);
            int c = com.aspose.imaging.CmykColorHelper.getC(cmyk);
            int m = com.aspose.imaging.CmykColorHelper.getM(cmyk);
            int y = com.aspose.imaging.CmykColorHelper.getY(cmyk);
            int k = com.aspose.imaging.CmykColorHelper.getK(cmyk);
        
            System.out.printf("RGB(@%s,%s,%s)\t\t=> CMYK(%s,%s,%s,%s)\r\n", rgbColor.getR() & 0xff, rgbColor.getG() & 0xff, rgbColor.getB() & 0xff, c, m, y, k);
        }
        
        //The output looks like this:
        //Convert RGB to CMYK without using ICC profiles.
        //RGB(255,0,0)        => CMYK(0,255,255,0)
        //RGB(0,128,0)        => CMYK(255,0,255,127)
        //RGB(0,0,255)        => CMYK(255,255,0,0)
        

      • fromComponents

        public static int fromComponents(int cyan,
                                         int magenta,
                                         int yellow,
                                         int black)

        Creates CMYK from a 32-bit cyan, magenta, yellow and black values.

        Parameters:
        cyan - The cyan component. Valid values are 0 through 255.
        magenta - The magenta component. Valid values are 0 through 255.
        yellow - The yellow component. Valid values are 0 through 255.
        black - The black component. Valid values are 0 through 255.
        Returns:
        The CMYK color presented as a 32-bit integer value.
        Code example:

        The following example shows how to convert CMYK colors to their RGB counterparts in a fast manner following straightforward formulas without using ICC profiles.


        int[] cmykColors = new int[]
                {
                        com.aspose.imaging.CmykColorHelper.fromComponents(255, 0, 0, 0),   // Cyan
                        com.aspose.imaging.CmykColorHelper.fromComponents(0, 255, 0, 0),   // Magenta
                        com.aspose.imaging.CmykColorHelper.fromComponents(0, 0, 255, 0),   // Yellow
                        com.aspose.imaging.CmykColorHelper.fromComponents(0, 0, 0, 255),   // Black
                };
        
        System.out.println("Convert CMYK to RGB without using ICC profiles.");
        for (int cmykColor : cmykColors) {
            com.aspose.imaging.Color rgbColor = com.aspose.imaging.CmykColorHelper.toArgb(cmykColor);
            int c = com.aspose.imaging.CmykColorHelper.getC(cmykColor);
            int m = com.aspose.imaging.CmykColorHelper.getM(cmykColor);
            int y = com.aspose.imaging.CmykColorHelper.getY(cmykColor);
            int k = com.aspose.imaging.CmykColorHelper.getK(cmykColor);
        
            System.out.printf("CMYK(%s,%s,%s,%s)\t\t=> RGB(%s,%s,%s)\r\n", c, m, y, k, rgbColor.getR() & 0xff, rgbColor.getG() & 0xff, (int) rgbColor.getB() & 0xff);
        }
        
        //The output looks like this:
        //Convert CMYK to RGB without using ICC profiles.
        //CMYK(255,0,0,0)        => RGB(0,255,255)
        //CMYK(0,255,0,0)        => RGB(255,0,255)
        //CMYK(0,0,255,0)        => RGB(255,255,0)
        //CMYK(0,0,0,255)        => RGB(0,0,0)
        

      • toCmyk

        public static int[] toCmyk(int[] argbPixels)

        The conversion from ARGB colors to CMYK colors.

        Parameters:
        argbPixels - The ARGB colors presented as 32-bit integer values.
        Returns:
        The CMYK colors presented as 32-bit integer values.
      • toCmykBytes

        public static byte[] toCmykBytes(int[] argbPixels,
                                         int startIndex,
                                         int length)

        Converts RGB to CMYK.

        Parameters:
        argbPixels - The RGB colors presented as 32-bit integer values.
        startIndex - The start index of RGB color.
        length - The number of RGB pixels to convert.
        Returns:
        The CMYK colors presented as a byte array.
      • toCmyk

        public static int toCmyk(int argbPixel)

        The conversion from ARGB color to CMYK color.

        Parameters:
        argbPixel - The ARGB color presented as a 32-bit integer value.
        Returns:
        The CMYK color presented as a 32-bit integer value.
      • toCmyk

        public static int toCmyk(Color pixel)

        The conversion from ARGB color to CMYK color.

        Parameters:
        pixel - The ARGB color.
        Returns:
        The CMYK color presented as a 32-bit integer value.
        Code example:

        The following example shows how to convert RGB colors to their CMYK counterparts without applying ICC profiles.


        com.aspose.imaging.Color[] rgbColors = new com.aspose.imaging.Color[]
                {
                        com.aspose.imaging.Color.getRed(),
                        com.aspose.imaging.Color.getGreen(),
                        com.aspose.imaging.Color.getBlue(),
                };
        
        System.out.println("Convert RGB to CMYK without using ICC profiles.");
        for (com.aspose.imaging.Color rgbColor : rgbColors) {
            int cmyk = com.aspose.imaging.CmykColorHelper.toCmyk(rgbColor);
            int c = com.aspose.imaging.CmykColorHelper.getC(cmyk);
            int m = com.aspose.imaging.CmykColorHelper.getM(cmyk);
            int y = com.aspose.imaging.CmykColorHelper.getY(cmyk);
            int k = com.aspose.imaging.CmykColorHelper.getK(cmyk);
        
            System.out.printf("RGB(@%s,%s,%s)\t\t=> CMYK(%s,%s,%s,%s)\r\n", rgbColor.getR() & 0xff, rgbColor.getG() & 0xff, rgbColor.getB() & 0xff, c, m, y, k);
        }
        
        //The output looks like this:
        //Convert RGB to CMYK without using ICC profiles.
        //RGB(255,0,0)        => CMYK(0,255,255,0)
        //RGB(0,128,0)        => CMYK(255,0,255,127)
        //RGB(0,0,255)        => CMYK(255,255,0,0)
        

      • toCmyk

        public static int[] toCmyk(Color[] pixels)

        The conversion from ARGB colors to CMYK colors.

        Parameters:
        pixels - The ARGB colors.
        Returns:
        The CMYK colors presented as 32-bit integer values.
      • toArgb

        public static Color[] toArgb(int[] cmykPixels)

        The conversion from CMYK colors to ARGB colors.

        Parameters:
        cmykPixels - The CMYK colors presented as 32-bit integer values.
        Returns:
        The ARGB colors.
      • toArgb

        public static Color toArgb(int cmykPixel)

        The conversion from CMYK color to ARGB color.

        Parameters:
        cmykPixel - The CMYK color presented as a 32-bit integer value.
        Returns:
        The ARGB color.
        Code example:

        The following example shows how to convert CMYK colors to their RGB counterparts in a fast manner following straightforward formulas without using ICC profiles.


        int[] cmykColors = new int[]
                {
                        com.aspose.imaging.CmykColorHelper.fromComponents(255, 0, 0, 0),   // Cyan
                        com.aspose.imaging.CmykColorHelper.fromComponents(0, 255, 0, 0),   // Magenta
                        com.aspose.imaging.CmykColorHelper.fromComponents(0, 0, 255, 0),   // Yellow
                        com.aspose.imaging.CmykColorHelper.fromComponents(0, 0, 0, 255),   // Black
                };
        
        System.out.println("Convert CMYK to RGB without using ICC profiles.");
        for (int cmykColor : cmykColors) {
            com.aspose.imaging.Color rgbColor = com.aspose.imaging.CmykColorHelper.toArgb(cmykColor);
            int c = com.aspose.imaging.CmykColorHelper.getC(cmykColor);
            int m = com.aspose.imaging.CmykColorHelper.getM(cmykColor);
            int y = com.aspose.imaging.CmykColorHelper.getY(cmykColor);
            int k = com.aspose.imaging.CmykColorHelper.getK(cmykColor);
        
            System.out.printf("CMYK(%s,%s,%s,%s)\t\t=> RGB(%s,%s,%s)\r\n", c, m, y, k, rgbColor.getR() & 0xff, rgbColor.getG() & 0xff, (int) rgbColor.getB() & 0xff);
        }
        
        //The output looks like this:
        //Convert CMYK to RGB without using ICC profiles.
        //CMYK(255,0,0,0)        => RGB(0,255,255)
        //CMYK(0,255,0,0)        => RGB(255,0,255)
        //CMYK(0,0,255,0)        => RGB(255,255,0)
        //CMYK(0,0,0,255)        => RGB(0,0,0)
        

      • toArgb32

        public static int[] toArgb32(int[] cmykPixels)

        The conversion from CMYK colors to ARGB colors.

        Parameters:
        cmykPixels - The CMYK colors presented as 32-bit integer values.
        Returns:
        The ARGB colors presented as 32-bit integer values.
      • toArgbIcc

        public static Color[] toArgbIcc(int[] cmykPixels)

        The conversion from CMYK colors to ARGB colors using Icc conversion with default profiles.

        Parameters:
        cmykPixels - The CMYK pixels presented as 32-bit integer values.
        Returns:
        The ARGB colors.
      • toArgbIcc

        public static Color[] toArgbIcc(int[] cmykPixels,
                                        InputStream cmykIccStream,
                                        InputStream rgbIccStream)

        The conversion from CMYK colors to ARGB colors using Icc conversion with custom profiles.

        Parameters:
        cmykPixels - The CMYK colors presented as 32-bit integer values.
        cmykIccStream - The stream containing CMYK Icc profile.
        rgbIccStream - The stream containing RGB Icc profile.
        Returns:
        The ARGB colors.
      • toArgbIcc

        public static Color toArgbIcc(int cmykPixel)

        The conversion from CMYK color to ARGB Color using Icc conversion with default profiles.

        Parameters:
        cmykPixel - The CMYK color presented as a 32-bit integer value.
        Returns:
        The ARGB color.
        Code example:

        The following example shows how to convert CMYK colors to their RGB counterparts using ICC profiles.


        int[] cmykColors = new int[]
                {
                        com.aspose.imaging.CmykColorHelper.fromComponents(255, 0, 0, 0),   // Cyan
                        com.aspose.imaging.CmykColorHelper.fromComponents(0, 255, 0, 0),   // Magenta
                        com.aspose.imaging.CmykColorHelper.fromComponents(0, 0, 255, 0),   // Yellow
                        com.aspose.imaging.CmykColorHelper.fromComponents(0, 0, 0, 255),   // Black
                };
        
        System.out.println("Convert CMYK to RGB using default ICC profiles.");
        for (int cmykColor : cmykColors) {
            com.aspose.imaging.Color rgbColor = com.aspose.imaging.CmykColorHelper.toArgbIcc(cmykColor);
            int c = com.aspose.imaging.CmykColorHelper.getC(cmykColor);
            int m = com.aspose.imaging.CmykColorHelper.getM(cmykColor);
            int y = com.aspose.imaging.CmykColorHelper.getY(cmykColor);
            int k = com.aspose.imaging.CmykColorHelper.getK(cmykColor);
        
            System.out.printf("CMYK(%s,%s,%s,%s)\t\t=> RGB(%s,%s,%s)\r\n", c, m, y, k, rgbColor.getR() & 0xff, rgbColor.getG() & 0xff, rgbColor.getB() & 0xff);
        }
        
        // Specify your path to custom RGB and CMYK ICC profiles.
        String dir = "c:\\temp\\iccprofiles\\";
        
        System.out.println("Convert CMYK to RGB using custom ICC profiles.");
        // Read all bytes from ICC files to memory to have a possibility to reset input profile stream before calling toCmykIcc
        byte[] rgbProfileBytes;
        java.io.RandomAccessFile rgbProfile = new java.io.RandomAccessFile(dir + "eciRGB_v2.icc", "r");
        try {
            rgbProfileBytes = new byte[(int) rgbProfile.length()];
            rgbProfile.readFully(rgbProfileBytes);
        } finally {
            rgbProfile.close();
        }
        
        byte[] cmykProfileBytes;
        java.io.RandomAccessFile cmykProfile = new java.io.RandomAccessFile(dir + "ISOcoated_v2_FullGamut4.icc", "r");
        try {
            cmykProfileBytes = new byte[(int) cmykProfile.length()];
            cmykProfile.readFully(cmykProfileBytes);
        } finally {
            cmykProfile.close();
        }
        
        java.io.InputStream rgbProfileStream = new java.io.ByteArrayInputStream(rgbProfileBytes);
        java.io.InputStream cmykProfileStream = new java.io.ByteArrayInputStream(cmykProfileBytes);
        try {
            for (int cmykColor : cmykColors) {
                com.aspose.imaging.Color rgbColor = com.aspose.imaging.CmykColorHelper.toArgbIcc(cmykColor);
                int c = com.aspose.imaging.CmykColorHelper.getC(cmykColor);
                int m = com.aspose.imaging.CmykColorHelper.getM(cmykColor);
                int y = com.aspose.imaging.CmykColorHelper.getY(cmykColor);
                int k = com.aspose.imaging.CmykColorHelper.getK(cmykColor);
        
                System.out.printf("CMYK(%s,%s,%s,%s)\t\t=> RGB(%s,%s,%s)\r\n", c, m, y, k, rgbColor.getR() & 0xff, rgbColor.getG() & 0xff, rgbColor.getB() & 0xff);
            }
        } finally {
            cmykProfileStream.close();
            rgbProfileStream.close();
        }
        
        //The output looks like this:
        //Convert CMYK to RGB using default ICC profiles.
        //CMYK(255,0,0,0)        => RGB(46,188,220)
        //CMYK(0,255,0,0)        => RGB(231,52,142)
        //CMYK(0,0,255,0)        => RGB(244,253,63)
        //CMYK(0,0,0,255)        => RGB(21,21,21)
        //Convert CMYK to RGB using custom ICC profiles.
        //CMYK(255,0,0,0)        => RGB(46,188,220)
        //CMYK(0,255,0,0)        => RGB(231,52,142)
        //(0,0,255,0)            => RGB(244,253,63)
        //CMYK(0,0,0,255)        => RGB(21,21,21)
        

      • toArgbIcc

        public static Color toArgbIcc(int cmykPixel,
                                      InputStream cmykIccStream,
                                      InputStream rgbIccStream)

        The conversion from CMYK color to ARGB color using Icc conversion with custom profile.

        Parameters:
        cmykPixel - The CMYK color presented as a 32-bit integer value.
        cmykIccStream - The stream containing CMYK Icc profile.
        rgbIccStream - The stream containing RGB Icc profile.
        Returns:
        The ARGB color.
        Code example:

        The following example shows how to convert CMYK colors to their RGB counterparts using ICC profiles.


        int[] cmykColors = new int[]
                {
                        com.aspose.imaging.CmykColorHelper.fromComponents(255, 0, 0, 0),   // Cyan
                        com.aspose.imaging.CmykColorHelper.fromComponents(0, 255, 0, 0),   // Magenta
                        com.aspose.imaging.CmykColorHelper.fromComponents(0, 0, 255, 0),   // Yellow
                        com.aspose.imaging.CmykColorHelper.fromComponents(0, 0, 0, 255),   // Black
                };
        
        System.out.println("Convert CMYK to RGB using default ICC profiles.");
        for (int cmykColor : cmykColors) {
            com.aspose.imaging.Color rgbColor = com.aspose.imaging.CmykColorHelper.toArgbIcc(cmykColor);
            int c = com.aspose.imaging.CmykColorHelper.getC(cmykColor);
            int m = com.aspose.imaging.CmykColorHelper.getM(cmykColor);
            int y = com.aspose.imaging.CmykColorHelper.getY(cmykColor);
            int k = com.aspose.imaging.CmykColorHelper.getK(cmykColor);
        
            System.out.printf("CMYK(%s,%s,%s,%s)\t\t=> RGB(%s,%s,%s)\r\n", c, m, y, k, rgbColor.getR() & 0xff, rgbColor.getG() & 0xff, rgbColor.getB() & 0xff);
        }
        
        // Specify your path to custom RGB and CMYK ICC profiles.
        String dir = "c:\\temp\\iccprofiles\\";
        
        System.out.println("Convert CMYK to RGB using custom ICC profiles.");
        // Read all bytes from ICC files to memory to have a possibility to reset input profile stream before calling toCmykIcc
        byte[] rgbProfileBytes;
        java.io.RandomAccessFile rgbProfile = new java.io.RandomAccessFile(dir + "eciRGB_v2.icc", "r");
        try {
            rgbProfileBytes = new byte[(int) rgbProfile.length()];
            rgbProfile.readFully(rgbProfileBytes);
        } finally {
            rgbProfile.close();
        }
        
        byte[] cmykProfileBytes;
        java.io.RandomAccessFile cmykProfile = new java.io.RandomAccessFile(dir + "ISOcoated_v2_FullGamut4.icc", "r");
        try {
            cmykProfileBytes = new byte[(int) cmykProfile.length()];
            cmykProfile.readFully(cmykProfileBytes);
        } finally {
            cmykProfile.close();
        }
        
        java.io.InputStream rgbProfileStream = new java.io.ByteArrayInputStream(rgbProfileBytes);
        java.io.InputStream cmykProfileStream = new java.io.ByteArrayInputStream(cmykProfileBytes);
        try {
            for (int cmykColor : cmykColors) {
                com.aspose.imaging.Color rgbColor = com.aspose.imaging.CmykColorHelper.toArgbIcc(cmykColor);
                int c = com.aspose.imaging.CmykColorHelper.getC(cmykColor);
                int m = com.aspose.imaging.CmykColorHelper.getM(cmykColor);
                int y = com.aspose.imaging.CmykColorHelper.getY(cmykColor);
                int k = com.aspose.imaging.CmykColorHelper.getK(cmykColor);
        
                System.out.printf("CMYK(%s,%s,%s,%s)\t\t=> RGB(%s,%s,%s)\r\n", c, m, y, k, rgbColor.getR() & 0xff, rgbColor.getG() & 0xff, rgbColor.getB() & 0xff);
            }
        } finally {
            cmykProfileStream.close();
            rgbProfileStream.close();
        }
        
        //The output looks like this:
        //Convert CMYK to RGB using default ICC profiles.
        //CMYK(255,0,0,0)        => RGB(46,188,220)
        //CMYK(0,255,0,0)        => RGB(231,52,142)
        //CMYK(0,0,255,0)        => RGB(244,253,63)
        //CMYK(0,0,0,255)        => RGB(21,21,21)
        //Convert CMYK to RGB using custom ICC profiles.
        //CMYK(255,0,0,0)        => RGB(46,188,220)
        //CMYK(0,255,0,0)        => RGB(231,52,142)
        //(0,0,255,0)            => RGB(244,253,63)
        //CMYK(0,0,0,255)        => RGB(21,21,21)
        

      • toCmykIcc

        public static int[] toCmykIcc(Color[] pixels,
                                      InputStream rgbIccStream,
                                      InputStream cmykIccStream)

        The conversion from ARGB colors to CMYK colors using Icc conversion with custom profiles.

        Parameters:
        pixels - The ARGB colors.
        rgbIccStream - The stream containing RGB Icc profile.
        cmykIccStream - The stream containing CMYK Icc profile.
        Returns:
        The CMYK colors presented as 32-bit integer values.
      • toCmykIccBytes

        public static byte[] toCmykIccBytes(int[] pixels,
                                            int startIndex,
                                            int length,
                                            InputStream rgbIccStream,
                                            InputStream cmykIccStream)

        Converts RGB to CMYK using custom ICC profiles.

        Parameters:
        pixels - The RGB colors presented as 32-bit integer values.
        startIndex - The start index of RGB color.
        length - The number of RGB pixels to convert.
        rgbIccStream - The RGB profile stream.
        cmykIccStream - The CMYK profile stream.
        Returns:
        The CMYK colors presented as a byte array.
      • toCmykIcc

        public static int[] toCmykIcc(Color[] pixels)

        The conversion from ARGB colors to CMYK colors using Icc conversion with default profiles.

        Parameters:
        pixels - The ARGB colors.
        Returns:
        The CMYK colors presented as 32-bit integer values.
      • toCmykIcc

        public static int toCmykIcc(Color pixel)

        The conversion from ARGB color to CMYK color using Icc conversion with default profiles.

        Parameters:
        pixel - The ARGB color.
        Returns:
        The CMYK color presented as a 32-bit integer value.
        Code example:

        The following example shows how to convert RGB colors to their CMYK counterparts using ICC profiles.


        com.aspose.imaging.Color[] rgbColors = new com.aspose.imaging.Color[]
                {
                        com.aspose.imaging.Color.getRed(),
                        com.aspose.imaging.Color.getGreen(),
                        com.aspose.imaging.Color.getBlue(),
                };
        
        System.out.println("Convert RGB to CMYK using default ICC profiles.");
        for (com.aspose.imaging.Color rgbColor : rgbColors) {
            int cmyk = com.aspose.imaging.CmykColorHelper.toCmykIcc(rgbColor);
            int c = com.aspose.imaging.CmykColorHelper.getC(cmyk);
            int m = com.aspose.imaging.CmykColorHelper.getM(cmyk);
            int y = com.aspose.imaging.CmykColorHelper.getY(cmyk);
            int k = com.aspose.imaging.CmykColorHelper.getK(cmyk);
        
            System.out.printf("RGB(%s,%s,%s)\t\t=> CMYK(%s,%s,%s,%s)\r\n", rgbColor.getR() & 0xff, rgbColor.getG() & 0xff, rgbColor.getB() & 0xff, c, m, y, k);
        }
        
        // Specify your path to the RGB and CMYK ICC profiles.
        String dir = "c:\\temp\\iccprofiles\\";
        
        System.out.println("Convert RGB to CMYK using custom ICC profiles.");
        
        // Read all bytes from ICC files to memory to have a possibility to reset input profile stream before calling toCmykIcc
        byte[] rgbProfileBytes;
        java.io.RandomAccessFile rgbProfile = new java.io.RandomAccessFile(dir + "eciRGB_v2.icc", "r");
        try {
            rgbProfileBytes = new byte[(int) rgbProfile.length()];
            rgbProfile.readFully(rgbProfileBytes);
        } finally {
            rgbProfile.close();
        }
        
        byte[] cmykProfileBytes;
        java.io.RandomAccessFile cmykProfile = new java.io.RandomAccessFile(dir + "ISOcoated_v2_FullGamut4.icc", "r");
        try {
            cmykProfileBytes = new byte[(int) cmykProfile.length()];
            cmykProfile.readFully(cmykProfileBytes);
        } finally {
            cmykProfile.close();
        }
        
        java.io.InputStream rgbProfileStream = new java.io.ByteArrayInputStream(rgbProfileBytes);
        java.io.InputStream cmykProfileStream = new java.io.ByteArrayInputStream(cmykProfileBytes);
        try {
            for (com.aspose.imaging.Color rgbColor : rgbColors) {
        
                int cmyk = com.aspose.imaging.CmykColorHelper.toCmykIcc(rgbColor, rgbProfileStream, cmykProfileStream);
                int c = com.aspose.imaging.CmykColorHelper.getC(cmyk);
                int m = com.aspose.imaging.CmykColorHelper.getM(cmyk);
                int y = com.aspose.imaging.CmykColorHelper.getY(cmyk);
                int k = com.aspose.imaging.CmykColorHelper.getK(cmyk);
        
                System.out.printf("RGB(%s,%s,%s)\t\t=> CMYK(%s,%s,%s,%s)\r\n", rgbColor.getR() & 0xff, rgbColor.getG() & 0xff, rgbColor.getB() & 0xff, c, m, y, k);
            }
        } finally {
            cmykProfileStream.close();
            rgbProfileStream.close();
        }
        
        //The output looks like this:
        //Convert RGB to CMYK using default ICC profiles.
        //RGB(255,0,0)        => CMYK(0,254,249,15)
        //RGB(0,128,0)        => CMYK(247,21,254,85)
        //RGB(0,0,255)        => CMYK(254,195,0,134)
        //Convert RGB to CMYK using custom ICC profiles.
        //RGB(255,0,0)        => CMYK(0,207,219,0)
        //RGB(0,128,0)        => CMYK(238,16,254,80)
        //RGB(0,0,255)        => CMYK(242,182,0,0)
        

      • toCmykIcc

        public static int toCmykIcc(Color pixel,
                                    InputStream rgbIccStream,
                                    InputStream cmykIccStream)

        The conversion from ARGB color to CMYK color using Icc conversion with custom profiles.

        Parameters:
        pixel - The ARGB color.
        rgbIccStream - The stream containing RGB Icc profile.
        cmykIccStream - The stream containing CMYK Icc profile.
        Returns:
        The CMYK color presented as a 32-bit integer value.
        Code example:

        The following example shows how to convert RGB colors to their CMYK counterparts using ICC profiles.


        com.aspose.imaging.Color[] rgbColors = new com.aspose.imaging.Color[]
                {
                        com.aspose.imaging.Color.getRed(),
                        com.aspose.imaging.Color.getGreen(),
                        com.aspose.imaging.Color.getBlue(),
                };
        
        System.out.println("Convert RGB to CMYK using default ICC profiles.");
        for (com.aspose.imaging.Color rgbColor : rgbColors) {
            int cmyk = com.aspose.imaging.CmykColorHelper.toCmykIcc(rgbColor);
            int c = com.aspose.imaging.CmykColorHelper.getC(cmyk);
            int m = com.aspose.imaging.CmykColorHelper.getM(cmyk);
            int y = com.aspose.imaging.CmykColorHelper.getY(cmyk);
            int k = com.aspose.imaging.CmykColorHelper.getK(cmyk);
        
            System.out.printf("RGB(%s,%s,%s)\t\t=> CMYK(%s,%s,%s,%s)\r\n", rgbColor.getR() & 0xff, rgbColor.getG() & 0xff, rgbColor.getB() & 0xff, c, m, y, k);
        }
        
        // Specify your path to the RGB and CMYK ICC profiles.
        String dir = "c:\\temp\\iccprofiles\\";
        
        System.out.println("Convert RGB to CMYK using custom ICC profiles.");
        
        // Read all bytes from ICC files to memory to have a possibility to reset input profile stream before calling toCmykIcc
        byte[] rgbProfileBytes;
        java.io.RandomAccessFile rgbProfile = new java.io.RandomAccessFile(dir + "eciRGB_v2.icc", "r");
        try {
            rgbProfileBytes = new byte[(int) rgbProfile.length()];
            rgbProfile.readFully(rgbProfileBytes);
        } finally {
            rgbProfile.close();
        }
        
        byte[] cmykProfileBytes;
        java.io.RandomAccessFile cmykProfile = new java.io.RandomAccessFile(dir + "ISOcoated_v2_FullGamut4.icc", "r");
        try {
            cmykProfileBytes = new byte[(int) cmykProfile.length()];
            cmykProfile.readFully(cmykProfileBytes);
        } finally {
            cmykProfile.close();
        }
        
        java.io.InputStream rgbProfileStream = new java.io.ByteArrayInputStream(rgbProfileBytes);
        java.io.InputStream cmykProfileStream = new java.io.ByteArrayInputStream(cmykProfileBytes);
        try {
            for (com.aspose.imaging.Color rgbColor : rgbColors) {
        
                int cmyk = com.aspose.imaging.CmykColorHelper.toCmykIcc(rgbColor, rgbProfileStream, cmykProfileStream);
                int c = com.aspose.imaging.CmykColorHelper.getC(cmyk);
                int m = com.aspose.imaging.CmykColorHelper.getM(cmyk);
                int y = com.aspose.imaging.CmykColorHelper.getY(cmyk);
                int k = com.aspose.imaging.CmykColorHelper.getK(cmyk);
        
                System.out.printf("RGB(%s,%s,%s)\t\t=> CMYK(%s,%s,%s,%s)\r\n", rgbColor.getR() & 0xff, rgbColor.getG() & 0xff, rgbColor.getB() & 0xff, c, m, y, k);
            }
        } finally {
            cmykProfileStream.close();
            rgbProfileStream.close();
        }
        
        //The output looks like this:
        //Convert RGB to CMYK using default ICC profiles.
        //RGB(255,0,0)        => CMYK(0,254,249,15)
        //RGB(0,128,0)        => CMYK(247,21,254,85)
        //RGB(0,0,255)        => CMYK(254,195,0,134)
        //Convert RGB to CMYK using custom ICC profiles.
        //RGB(255,0,0)        => CMYK(0,207,219,0)
        //RGB(0,128,0)        => CMYK(238,16,254,80)
        //RGB(0,0,255)        => CMYK(242,182,0,0)