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.
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.
|
public static int getC(int cmyk)
Gets the cyan component value.
cmyk
- The CMYK color presented as a 32-bit integer value.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)
public static int getM(int cmyk)
Gets the magenta component value.
cmyk
- The CMYK color presented as a 32-bit integer value.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)
public static int getY(int cmyk)
Gets the yellow component value.
cmyk
- The CMYK color presented as a 32-bit integer value.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)
public static int getK(int cmyk)
Gets the black component value.
cmyk
- The CMYK color presented as a 32-bit integer value.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)
public static int fromComponents(int cyan, int magenta, int yellow, int black)
Creates CMYK from a 32-bit cyan, magenta, yellow and black values.
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.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)
public static int[] toCmyk(int[] argbPixels)
The conversion from ARGB colors to CMYK colors.
argbPixels
- The ARGB colors presented as 32-bit integer values.public static byte[] toCmykBytes(int[] argbPixels, int startIndex, int length)
Converts RGB to CMYK.
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.public static int toCmyk(int argbPixel)
The conversion from ARGB color to CMYK color.
argbPixel
- The ARGB color presented as a 32-bit integer value.public static int toCmyk(Color pixel)
The conversion from ARGB color to CMYK color.
pixel
- The ARGB color.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)
public static int[] toCmyk(Color[] pixels)
The conversion from ARGB colors to CMYK colors.
pixels
- The ARGB colors.public static Color[] toArgb(int[] cmykPixels)
The conversion from CMYK colors to ARGB colors.
cmykPixels
- The CMYK colors presented as 32-bit integer values.public static Color toArgb(int cmykPixel)
The conversion from CMYK color to ARGB color.
cmykPixel
- The CMYK color presented as a 32-bit integer value.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)
public static int[] toArgb32(int[] cmykPixels)
The conversion from CMYK colors to ARGB colors.
cmykPixels
- The CMYK colors presented as 32-bit integer values.public static Color[] toArgbIcc(int[] cmykPixels)
The conversion from CMYK colors to ARGB colors using Icc conversion with default profiles.
cmykPixels
- The CMYK pixels presented as 32-bit integer values.public static Color[] toArgbIcc(int[] cmykPixels, InputStream cmykIccStream, InputStream rgbIccStream)
The conversion from CMYK colors to ARGB colors using Icc conversion with custom profiles.
cmykPixels
- The CMYK colors presented as 32-bit integer values.cmykIccStream
- The stream containing CMYK Icc profile.rgbIccStream
- The stream containing RGB Icc profile.public static Color toArgbIcc(int cmykPixel)
The conversion from CMYK color to ARGB Color using Icc conversion with default profiles.
cmykPixel
- The CMYK color presented as a 32-bit integer value.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)
public static Color toArgbIcc(int cmykPixel, InputStream cmykIccStream, InputStream rgbIccStream)
The conversion from CMYK color to ARGB color using Icc conversion with custom profile.
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.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)
public static int[] toCmykIcc(Color[] pixels, InputStream rgbIccStream, InputStream cmykIccStream)
The conversion from ARGB colors to CMYK colors using Icc conversion with custom profiles.
pixels
- The ARGB colors.rgbIccStream
- The stream containing RGB Icc profile.cmykIccStream
- The stream containing CMYK Icc profile.public static byte[] toCmykIccBytes(int[] pixels, int startIndex, int length, InputStream rgbIccStream, InputStream cmykIccStream)
Converts RGB to CMYK using custom ICC profiles.
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.public static int[] toCmykIcc(Color[] pixels)
The conversion from ARGB colors to CMYK colors using Icc conversion with default profiles.
pixels
- The ARGB colors.public static int toCmykIcc(Color pixel)
The conversion from ARGB color to CMYK color using Icc conversion with default profiles.
pixel
- The ARGB color.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)
public static int toCmykIcc(Color pixel, InputStream rgbIccStream, InputStream cmykIccStream)
The conversion from ARGB color to CMYK color using Icc conversion with custom profiles.
pixel
- The ARGB color.rgbIccStream
- The stream containing RGB Icc profile.cmykIccStream
- The stream containing CMYK Icc profile.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)