Class CmykColorHelper
Namespace: Aspose.Imaging
Assembly: Aspose.Imaging.dll (25.8.0)
Helper methods to work with CMYK color presented as a signed 32-bit integer value. Provides the similar API as the 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 Aspose.Imaging.CmykColor struct.
public static class CmykColorHelperInheritance
Inherited Members
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Methods
FromComponents(int, int, int, int)
Creates CMYK from a 32-bit cyan, magenta, yellow and black values.
public static int FromComponents(int cyan, int magenta, int yellow, int black)Parameters
cyan int
The cyan component. Valid values are 0 through 255.
magenta int
The magenta component. Valid values are 0 through 255.
yellow int
The yellow component. Valid values are 0 through 255.
black int
The black component. Valid values are 0 through 255.
Returns
The CMYK color presented as a 32-bit integer value.
Examples
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[]
{
Aspose.Imaging.CmykColorHelper.FromComponents(255, 0, 0, 0), // Cyan
Aspose.Imaging.CmykColorHelper.FromComponents(0, 255, 0, 0), // Magenta
Aspose.Imaging.CmykColorHelper.FromComponents(0, 0, 255, 0), // Yellow
Aspose.Imaging.CmykColorHelper.FromComponents(0, 0, 0, 255), // Black
};
System.Console.WriteLine("Convert CMYK to RGB without using ICC profiles.");
foreach (int cmykColor in cmykColors)
{
Aspose.Imaging.Color rgbColor = Aspose.Imaging.CmykColorHelper.ToArgb(cmykColor);
int c = Aspose.Imaging.CmykColorHelper.GetC(cmykColor);
int m = Aspose.Imaging.CmykColorHelper.GetM(cmykColor);
int y = Aspose.Imaging.CmykColorHelper.GetY(cmykColor);
int k = Aspose.Imaging.CmykColorHelper.GetK(cmykColor);
System.Console.WriteLine("CMYK({0},{1},{2},{3})\t\t=> RGB({4},{5},{6})", c, m, y, k, rgbColor.R, rgbColor.G, rgbColor.B);
}
//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)GetC(int)
Gets the cyan component value.
public static int GetC(int cmyk)Parameters
cmyk int
The CMYK color presented as a 32-bit integer value.
Returns
The cyan component value.
Examples
The following example shows how to convert RGB colors to their CMYK counterparts without applying ICC profiles.
Aspose.Imaging.Color[] rgbColors = new Aspose.Imaging.Color[]
{
Aspose.Imaging.Color.Red,
Aspose.Imaging.Color.Green,
Aspose.Imaging.Color.Blue,
};
System.Console.WriteLine("Convert RGB to CMYK without using ICC profiles.");
foreach (Aspose.Imaging.Color rgbColor in rgbColors)
{
int cmyk = Aspose.Imaging.CmykColorHelper.ToCmyk(rgbColor);
int c = Aspose.Imaging.CmykColorHelper.GetC(cmyk);
int m = Aspose.Imaging.CmykColorHelper.GetM(cmyk);
int y = Aspose.Imaging.CmykColorHelper.GetY(cmyk);
int k = Aspose.Imaging.CmykColorHelper.GetK(cmyk);
System.Console.WriteLine("RGB({0},{1},{2})\t\t=> CMYK({3},{4},{5},{6})", rgbColor.R, rgbColor.G, rgbColor.B, 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)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[]
{
Aspose.Imaging.CmykColorHelper.FromComponents(255, 0, 0, 0), // Cyan
Aspose.Imaging.CmykColorHelper.FromComponents(0, 255, 0, 0), // Magenta
Aspose.Imaging.CmykColorHelper.FromComponents(0, 0, 255, 0), // Yellow
Aspose.Imaging.CmykColorHelper.FromComponents(0, 0, 0, 255), // Black
};
System.Console.WriteLine("Convert CMYK to RGB without using ICC profiles.");
foreach (int cmykColor in cmykColors)
{
Aspose.Imaging.Color rgbColor = Aspose.Imaging.CmykColorHelper.ToArgb(cmykColor);
int c = Aspose.Imaging.CmykColorHelper.GetC(cmykColor);
int m = Aspose.Imaging.CmykColorHelper.GetM(cmykColor);
int y = Aspose.Imaging.CmykColorHelper.GetY(cmykColor);
int k = Aspose.Imaging.CmykColorHelper.GetK(cmykColor);
System.Console.WriteLine("CMYK({0},{1},{2},{3})\t\t=> RGB({4},{5},{6})", c, m, y, k, rgbColor.R, rgbColor.G, rgbColor.B);
}
//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)GetK(int)
Gets the black component value.
public static int GetK(int cmyk)Parameters
cmyk int
The CMYK color presented as a 32-bit integer value.
Returns
The black component value.
Examples
The following example shows how to convert RGB colors to their CMYK counterparts without applying ICC profiles.
Aspose.Imaging.Color[] rgbColors = new Aspose.Imaging.Color[]
{
Aspose.Imaging.Color.Red,
Aspose.Imaging.Color.Green,
Aspose.Imaging.Color.Blue,
};
System.Console.WriteLine("Convert RGB to CMYK without using ICC profiles.");
foreach (Aspose.Imaging.Color rgbColor in rgbColors)
{
int cmyk = Aspose.Imaging.CmykColorHelper.ToCmyk(rgbColor);
int c = Aspose.Imaging.CmykColorHelper.GetC(cmyk);
int m = Aspose.Imaging.CmykColorHelper.GetM(cmyk);
int y = Aspose.Imaging.CmykColorHelper.GetY(cmyk);
int k = Aspose.Imaging.CmykColorHelper.GetK(cmyk);
System.Console.WriteLine("RGB({0},{1},{2})\t\t=> CMYK({3},{4},{5},{6})", rgbColor.R, rgbColor.G, rgbColor.B, 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)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[]
{
Aspose.Imaging.CmykColorHelper.FromComponents(255, 0, 0, 0), // Cyan
Aspose.Imaging.CmykColorHelper.FromComponents(0, 255, 0, 0), // Magenta
Aspose.Imaging.CmykColorHelper.FromComponents(0, 0, 255, 0), // Yellow
Aspose.Imaging.CmykColorHelper.FromComponents(0, 0, 0, 255), // Black
};
System.Console.WriteLine("Convert CMYK to RGB without using ICC profiles.");
foreach (int cmykColor in cmykColors)
{
Aspose.Imaging.Color rgbColor = Aspose.Imaging.CmykColorHelper.ToArgb(cmykColor);
int c = Aspose.Imaging.CmykColorHelper.GetC(cmykColor);
int m = Aspose.Imaging.CmykColorHelper.GetM(cmykColor);
int y = Aspose.Imaging.CmykColorHelper.GetY(cmykColor);
int k = Aspose.Imaging.CmykColorHelper.GetK(cmykColor);
System.Console.WriteLine("CMYK({0},{1},{2},{3})\t\t=> RGB({4},{5},{6})", c, m, y, k, rgbColor.R, rgbColor.G, rgbColor.B);
}
//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)GetM(int)
Gets the magenta component value.
public static int GetM(int cmyk)Parameters
cmyk int
The CMYK color presented as a 32-bit integer value.
Returns
The magenta component value.
Examples
The following example shows how to convert RGB colors to their CMYK counterparts without applying ICC profiles.
Aspose.Imaging.Color[] rgbColors = new Aspose.Imaging.Color[]
{
Aspose.Imaging.Color.Red,
Aspose.Imaging.Color.Green,
Aspose.Imaging.Color.Blue,
};
System.Console.WriteLine("Convert RGB to CMYK without using ICC profiles.");
foreach (Aspose.Imaging.Color rgbColor in rgbColors)
{
int cmyk = Aspose.Imaging.CmykColorHelper.ToCmyk(rgbColor);
int c = Aspose.Imaging.CmykColorHelper.GetC(cmyk);
int m = Aspose.Imaging.CmykColorHelper.GetM(cmyk);
int y = Aspose.Imaging.CmykColorHelper.GetY(cmyk);
int k = Aspose.Imaging.CmykColorHelper.GetK(cmyk);
System.Console.WriteLine("RGB({0},{1},{2})\t\t=> CMYK({3},{4},{5},{6})", rgbColor.R, rgbColor.G, rgbColor.B, 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)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[]
{
Aspose.Imaging.CmykColorHelper.FromComponents(255, 0, 0, 0), // Cyan
Aspose.Imaging.CmykColorHelper.FromComponents(0, 255, 0, 0), // Magenta
Aspose.Imaging.CmykColorHelper.FromComponents(0, 0, 255, 0), // Yellow
Aspose.Imaging.CmykColorHelper.FromComponents(0, 0, 0, 255), // Black
};
System.Console.WriteLine("Convert CMYK to RGB without using ICC profiles.");
foreach (int cmykColor in cmykColors)
{
Aspose.Imaging.Color rgbColor = Aspose.Imaging.CmykColorHelper.ToArgb(cmykColor);
int c = Aspose.Imaging.CmykColorHelper.GetC(cmykColor);
int m = Aspose.Imaging.CmykColorHelper.GetM(cmykColor);
int y = Aspose.Imaging.CmykColorHelper.GetY(cmykColor);
int k = Aspose.Imaging.CmykColorHelper.GetK(cmykColor);
System.Console.WriteLine("CMYK({0},{1},{2},{3})\t\t=> RGB({4},{5},{6})", c, m, y, k, rgbColor.R, rgbColor.G, rgbColor.B);
}
//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)GetY(int)
Gets the yellow component value.
public static int GetY(int cmyk)Parameters
cmyk int
The CMYK color presented as a 32-bit integer value.
Returns
The yellow component value.
Examples
The following example shows how to convert RGB colors to their CMYK counterparts without applying ICC profiles.
Aspose.Imaging.Color[] rgbColors = new Aspose.Imaging.Color[]
{
Aspose.Imaging.Color.Red,
Aspose.Imaging.Color.Green,
Aspose.Imaging.Color.Blue,
};
System.Console.WriteLine("Convert RGB to CMYK without using ICC profiles.");
foreach (Aspose.Imaging.Color rgbColor in rgbColors)
{
int cmyk = Aspose.Imaging.CmykColorHelper.ToCmyk(rgbColor);
int c = Aspose.Imaging.CmykColorHelper.GetC(cmyk);
int m = Aspose.Imaging.CmykColorHelper.GetM(cmyk);
int y = Aspose.Imaging.CmykColorHelper.GetY(cmyk);
int k = Aspose.Imaging.CmykColorHelper.GetK(cmyk);
System.Console.WriteLine("RGB({0},{1},{2})\t\t=> CMYK({3},{4},{5},{6})", rgbColor.R, rgbColor.G, rgbColor.B, 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)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[]
{
Aspose.Imaging.CmykColorHelper.FromComponents(255, 0, 0, 0), // Cyan
Aspose.Imaging.CmykColorHelper.FromComponents(0, 255, 0, 0), // Magenta
Aspose.Imaging.CmykColorHelper.FromComponents(0, 0, 255, 0), // Yellow
Aspose.Imaging.CmykColorHelper.FromComponents(0, 0, 0, 255), // Black
};
System.Console.WriteLine("Convert CMYK to RGB without using ICC profiles.");
foreach (int cmykColor in cmykColors)
{
Aspose.Imaging.Color rgbColor = Aspose.Imaging.CmykColorHelper.ToArgb(cmykColor);
int c = Aspose.Imaging.CmykColorHelper.GetC(cmykColor);
int m = Aspose.Imaging.CmykColorHelper.GetM(cmykColor);
int y = Aspose.Imaging.CmykColorHelper.GetY(cmykColor);
int k = Aspose.Imaging.CmykColorHelper.GetK(cmykColor);
System.Console.WriteLine("CMYK({0},{1},{2},{3})\t\t=> RGB({4},{5},{6})", c, m, y, k, rgbColor.R, rgbColor.G, rgbColor.B);
}
//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)ToArgb(int[])
The conversion from CMYK colors to ARGB colors.
public static Color[] ToArgb(int[] cmykPixels)Parameters
cmykPixels int
[]
The CMYK colors presented as 32-bit integer values.
Returns
Color []
The ARGB colors.
ToArgb(int)
The conversion from CMYK color to ARGB color.
public static Color ToArgb(int cmykPixel)Parameters
cmykPixel int
The CMYK color presented as a 32-bit integer value.
Returns
The ARGB color.
Examples
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[]
{
Aspose.Imaging.CmykColorHelper.FromComponents(255, 0, 0, 0), // Cyan
Aspose.Imaging.CmykColorHelper.FromComponents(0, 255, 0, 0), // Magenta
Aspose.Imaging.CmykColorHelper.FromComponents(0, 0, 255, 0), // Yellow
Aspose.Imaging.CmykColorHelper.FromComponents(0, 0, 0, 255), // Black
};
System.Console.WriteLine("Convert CMYK to RGB without using ICC profiles.");
foreach (int cmykColor in cmykColors)
{
Aspose.Imaging.Color rgbColor = Aspose.Imaging.CmykColorHelper.ToArgb(cmykColor);
int c = Aspose.Imaging.CmykColorHelper.GetC(cmykColor);
int m = Aspose.Imaging.CmykColorHelper.GetM(cmykColor);
int y = Aspose.Imaging.CmykColorHelper.GetY(cmykColor);
int k = Aspose.Imaging.CmykColorHelper.GetK(cmykColor);
System.Console.WriteLine("CMYK({0},{1},{2},{3})\t\t=> RGB({4},{5},{6})", c, m, y, k, rgbColor.R, rgbColor.G, rgbColor.B);
}
//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(int[])
The conversion from CMYK colors to ARGB colors.
public static int[] ToArgb32(int[] cmykPixels)Parameters
cmykPixels int
[]
The CMYK colors presented as 32-bit integer values.
Returns
int []
The ARGB colors presented as 32-bit integer values.
ToArgbIcc(int[])
The conversion from CMYK colors to ARGB colors using Icc conversion with default profiles.
public static Color[] ToArgbIcc(int[] cmykPixels)Parameters
cmykPixels int
[]
The CMYK pixels presented as 32-bit integer values.
Returns
Color []
The ARGB colors.
ToArgbIcc(int[], Stream, Stream)
The conversion from CMYK colors to ARGB colors using Icc conversion with custom profiles.
public static Color[] ToArgbIcc(int[] cmykPixels, Stream cmykIccStream, Stream rgbIccStream)Parameters
cmykPixels int
[]
The CMYK colors presented as 32-bit integer values.
cmykIccStream Stream
The stream containing CMYK Icc profile.
rgbIccStream Stream
The stream containing RGB Icc profile.
Returns
Color []
The ARGB colors.
ToArgbIcc(int)
The conversion from CMYK color to ARGB Color using Icc conversion with default profiles.
public static Color ToArgbIcc(int cmykPixel)Parameters
cmykPixel int
The CMYK color presented as a 32-bit integer value.
Returns
The ARGB color.
Examples
The following example shows how to convert CMYK colors to their RGB counterparts using ICC profiles.
int[] cmykColors = new int[]
{
Aspose.Imaging.CmykColorHelper.FromComponents(255, 0, 0, 0), // Cyan
Aspose.Imaging.CmykColorHelper.FromComponents(0, 255, 0, 0), // Magenta
Aspose.Imaging.CmykColorHelper.FromComponents(0, 0, 255, 0), // Yellow
Aspose.Imaging.CmykColorHelper.FromComponents(0, 0, 0, 255), // Black
};
System.Console.WriteLine("Convert CMYK to RGB using default ICC profiles.");
foreach (int cmykColor in cmykColors)
{
Aspose.Imaging.Color rgbColor = Aspose.Imaging.CmykColorHelper.ToArgbIcc(cmykColor);
int c = Aspose.Imaging.CmykColorHelper.GetC(cmykColor);
int m = Aspose.Imaging.CmykColorHelper.GetM(cmykColor);
int y = Aspose.Imaging.CmykColorHelper.GetY(cmykColor);
int k = Aspose.Imaging.CmykColorHelper.GetK(cmykColor);
System.Console.WriteLine("CMYK({0},{1},{2},{3})\t\t=> RGB({4},{5},{6})", c, m, y, k, rgbColor.R, rgbColor.G, rgbColor.B);
}
// Specify your path to custom RGB and CMYK ICC profiles.
string dir = "c:\\temp\\iccprofiles\\";
System.Console.WriteLine("Convert CMYK to RGB using custom ICC profiles.");
using (System.IO.Stream rgbProfileStream = System.IO.File.OpenRead(dir + "eciRGB_v2.icc"))
using (System.IO.Stream cmykProfileStream = System.IO.File.OpenRead(dir + "ISOcoated_v2_FullGamut4.icc"))
{
foreach (int cmykColor in cmykColors)
{
Aspose.Imaging.Color rgbColor = Aspose.Imaging.CmykColorHelper.ToArgbIcc(cmykColor);
int c = Aspose.Imaging.CmykColorHelper.GetC(cmykColor);
int m = Aspose.Imaging.CmykColorHelper.GetM(cmykColor);
int y = Aspose.Imaging.CmykColorHelper.GetY(cmykColor);
int k = Aspose.Imaging.CmykColorHelper.GetK(cmykColor);
System.Console.WriteLine("CMYK({0},{1},{2},{3})\t\t=> RGB({4},{5},{6})", c, m, y, k, rgbColor.R, rgbColor.G, rgbColor.B);
}
}
//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(int, Stream, Stream)
The conversion from CMYK color to ARGB color using Icc conversion with custom profile.
public static Color ToArgbIcc(int cmykPixel, Stream cmykIccStream, Stream rgbIccStream)Parameters
cmykPixel int
The CMYK color presented as a 32-bit integer value.
cmykIccStream Stream
The stream containing CMYK Icc profile.
rgbIccStream Stream
The stream containing RGB Icc profile.
Returns
The ARGB color.
Examples
The following example shows how to convert CMYK colors to their RGB counterparts using ICC profiles.
int[] cmykColors = new int[]
{
Aspose.Imaging.CmykColorHelper.FromComponents(255, 0, 0, 0), // Cyan
Aspose.Imaging.CmykColorHelper.FromComponents(0, 255, 0, 0), // Magenta
Aspose.Imaging.CmykColorHelper.FromComponents(0, 0, 255, 0), // Yellow
Aspose.Imaging.CmykColorHelper.FromComponents(0, 0, 0, 255), // Black
};
System.Console.WriteLine("Convert CMYK to RGB using default ICC profiles.");
foreach (int cmykColor in cmykColors)
{
Aspose.Imaging.Color rgbColor = Aspose.Imaging.CmykColorHelper.ToArgbIcc(cmykColor);
int c = Aspose.Imaging.CmykColorHelper.GetC(cmykColor);
int m = Aspose.Imaging.CmykColorHelper.GetM(cmykColor);
int y = Aspose.Imaging.CmykColorHelper.GetY(cmykColor);
int k = Aspose.Imaging.CmykColorHelper.GetK(cmykColor);
System.Console.WriteLine("CMYK({0},{1},{2},{3})\t\t=> RGB({4},{5},{6})", c, m, y, k, rgbColor.R, rgbColor.G, rgbColor.B);
}
// Specify your path to custom RGB and CMYK ICC profiles.
string dir = "c:\\temp\\iccprofiles\\";
System.Console.WriteLine("Convert CMYK to RGB using custom ICC profiles.");
using (System.IO.Stream rgbProfileStream = System.IO.File.OpenRead(dir + "eciRGB_v2.icc"))
using (System.IO.Stream cmykProfileStream = System.IO.File.OpenRead(dir + "ISOcoated_v2_FullGamut4.icc"))
{
foreach (int cmykColor in cmykColors)
{
Aspose.Imaging.Color rgbColor = Aspose.Imaging.CmykColorHelper.ToArgbIcc(cmykColor);
int c = Aspose.Imaging.CmykColorHelper.GetC(cmykColor);
int m = Aspose.Imaging.CmykColorHelper.GetM(cmykColor);
int y = Aspose.Imaging.CmykColorHelper.GetY(cmykColor);
int k = Aspose.Imaging.CmykColorHelper.GetK(cmykColor);
System.Console.WriteLine("CMYK({0},{1},{2},{3})\t\t=> RGB({4},{5},{6})", c, m, y, k, rgbColor.R, rgbColor.G, rgbColor.B);
}
}
//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)ToCmyk(int[])
The conversion from ARGB colors to CMYK colors.
public static int[] ToCmyk(int[] argbPixels)Parameters
argbPixels int
[]
The ARGB colors presented as 32-bit integer values.
Returns
int []
The CMYK colors presented as 32-bit integer values.
ToCmyk(int)
The conversion from ARGB color to CMYK color.
public static int ToCmyk(int argbPixel)Parameters
argbPixel int
The ARGB color presented as a 32-bit integer value.
Returns
The CMYK color presented as a 32-bit integer value.
ToCmyk(Color)
The conversion from ARGB color to CMYK color.
public static int ToCmyk(Color pixel)Parameters
pixel Color
The ARGB color.
Returns
The CMYK color presented as a 32-bit integer value.
Examples
The following example fills the central area of a raster image with black pixels using the Aspose.Imaging.RasterImage.SaveCmyk32Pixels method.
string dir = @"c:\temp\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Get an integer representation of black in the CMYK color space.
int blackCmyk = Aspose.Imaging.CmykColorHelper.ToCmyk(Color.Black);
// The black square.
int[] pixels = new int[(rasterImage.Width / 2) * (rasterImage.Height / 2)];
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = blackCmyk;
}
// Draw the black square at the center of the image.
Aspose.Imaging.Rectangle area = new Aspose.Imaging.Rectangle(rasterImage.Width / 4, rasterImage.Height / 4, rasterImage.Width / 2, rasterImage.Height / 2);
rasterImage.SaveCmyk32Pixels(area, pixels);
rasterImage.Save(dir + "sample.SaveCmyk32Pixels.png");
}The following example shows how to convert RGB colors to their CMYK counterparts without applying ICC profiles.
Aspose.Imaging.Color[] rgbColors = new Aspose.Imaging.Color[]
{
Aspose.Imaging.Color.Red,
Aspose.Imaging.Color.Green,
Aspose.Imaging.Color.Blue,
};
System.Console.WriteLine("Convert RGB to CMYK without using ICC profiles.");
foreach (Aspose.Imaging.Color rgbColor in rgbColors)
{
int cmyk = Aspose.Imaging.CmykColorHelper.ToCmyk(rgbColor);
int c = Aspose.Imaging.CmykColorHelper.GetC(cmyk);
int m = Aspose.Imaging.CmykColorHelper.GetM(cmyk);
int y = Aspose.Imaging.CmykColorHelper.GetY(cmyk);
int k = Aspose.Imaging.CmykColorHelper.GetK(cmyk);
System.Console.WriteLine("RGB({0},{1},{2})\t\t=> CMYK({3},{4},{5},{6})", rgbColor.R, rgbColor.G, rgbColor.B, 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(Color[])
The conversion from ARGB colors to CMYK colors.
public static int[] ToCmyk(Color[] pixels)Parameters
pixels Color
[]
The ARGB colors.
Returns
int []
The CMYK colors presented as 32-bit integer values.
ToCmykBytes(int[], int, int)
Converts ARGB to CMYK.
public static byte[] ToCmykBytes(int[] argbPixels, int startIndex, int length)Parameters
argbPixels int
[]
The RGB colors presented as 32-bit integer values.
startIndex int
The start index of RGB color.
length int
The number of RGB pixels to convert.
Returns
byte []
The CMYK colors presented as a byte array.
ToCmykIcc(Color[], Stream, Stream)
The conversion from ARGB colors to CMYK colors using Icc conversion with custom profiles.
public static int[] ToCmykIcc(Color[] pixels, Stream rgbIccStream, Stream cmykIccStream)Parameters
pixels Color
[]
The ARGB colors.
rgbIccStream Stream
The stream containing RGB Icc profile.
cmykIccStream Stream
The stream containing CMYK Icc profile.
Returns
int []
The CMYK colors presented as 32-bit integer values.
ToCmykIcc(int[], Stream, Stream)
The conversion from ARGB colors to CMYK colors using Icc conversion with custom profiles.
public static int[] ToCmykIcc(int[] pixels, Stream rgbIccStream, Stream cmykIccStream)Parameters
pixels int
[]
The ARGB colors.
rgbIccStream Stream
The stream containing RGB Icc profile.
cmykIccStream Stream
The stream containing CMYK Icc profile.
Returns
int []
The CMYK colors presented as 32-bit integer values.
ToCmykIcc(Color[])
The conversion from ARGB colors to CMYK colors using Icc conversion with default profiles.
public static int[] ToCmykIcc(Color[] pixels)Parameters
pixels Color
[]
The ARGB colors.
Returns
int []
The CMYK colors presented as 32-bit integer values.
ToCmykIcc(int[])
The conversion from ARGB colors to CMYK colors using Icc conversion with default profiles.
public static int[] ToCmykIcc(int[] pixels)Parameters
pixels int
[]
The ARGB colors.
Returns
int []
The CMYK colors presented as 32-bit integer values.
ToCmykIcc(Color)
The conversion from ARGB color to CMYK color using Icc conversion with default profiles.
public static int ToCmykIcc(Color pixel)Parameters
pixel Color
The ARGB color.
Returns
The CMYK color presented as a 32-bit integer value.
Examples
The following example shows how to convert RGB colors to their CMYK counterparts using ICC profiles.
Aspose.Imaging.Color[] rgbColors = new Aspose.Imaging.Color[]
{
Aspose.Imaging.Color.Red,
Aspose.Imaging.Color.Green,
Aspose.Imaging.Color.Blue,
};
System.Console.WriteLine("Convert RGB to CMYK using default ICC profiles.");
foreach (Aspose.Imaging.Color rgbColor in rgbColors)
{
int cmyk = Aspose.Imaging.CmykColorHelper.ToCmykIcc(rgbColor);
int c = Aspose.Imaging.CmykColorHelper.GetC(cmyk);
int m = Aspose.Imaging.CmykColorHelper.GetM(cmyk);
int y = Aspose.Imaging.CmykColorHelper.GetY(cmyk);
int k = Aspose.Imaging.CmykColorHelper.GetK(cmyk);
System.Console.WriteLine("RGB({0},{1},{2})\t\t=> CMYK({3},{4},{5},{6})", rgbColor.R, rgbColor.G, rgbColor.B, c, m, y, k);
}
// Specify your path to the RGB and CMYK ICC profiles.
string dir = "c:\\temp\\iccprofiles\\";
System.Console.WriteLine("Convert RGB to CMYK using custom ICC profiles.");
using (System.IO.Stream rgbProfileStream = System.IO.File.OpenRead(dir + "eciRGB_v2.icc"))
using (System.IO.Stream cmykProfileStream = System.IO.File.OpenRead(dir + "ISOcoated_v2_FullGamut4.icc"))
{
foreach (Aspose.Imaging.Color rgbColor in rgbColors)
{
int cmyk = Aspose.Imaging.CmykColorHelper.ToCmykIcc(rgbColor, rgbProfileStream, cmykProfileStream);
int c = Aspose.Imaging.CmykColorHelper.GetC(cmyk);
int m = Aspose.Imaging.CmykColorHelper.GetM(cmyk);
int y = Aspose.Imaging.CmykColorHelper.GetY(cmyk);
int k = Aspose.Imaging.CmykColorHelper.GetK(cmyk);
System.Console.WriteLine("RGB({0},{1},{2})\t\t=> CMYK({3},{4},{5},{6})", rgbColor.R, rgbColor.G, rgbColor.B, c, m, y, k);
}
}
//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(int)
The conversion from ARGB color to CMYK color using Icc conversion with default profiles.
public static int ToCmykIcc(int argb)Parameters
argb int
The ARGB color.
Returns
The CMYK color presented as a 32-bit integer value.
ToCmykIcc(Color, Stream, Stream)
The conversion from ARGB color to CMYK color using Icc conversion with custom profiles.
public static int ToCmykIcc(Color pixel, Stream rgbIccStream, Stream cmykIccStream)Parameters
pixel Color
The ARGB color.
rgbIccStream Stream
The stream containing RGB Icc profile.
cmykIccStream Stream
The stream containing CMYK Icc profile.
Returns
The CMYK color presented as a 32-bit integer value.
Examples
The following example shows how to convert RGB colors to their CMYK counterparts using ICC profiles.
Aspose.Imaging.Color[] rgbColors = new Aspose.Imaging.Color[]
{
Aspose.Imaging.Color.Red,
Aspose.Imaging.Color.Green,
Aspose.Imaging.Color.Blue,
};
System.Console.WriteLine("Convert RGB to CMYK using default ICC profiles.");
foreach (Aspose.Imaging.Color rgbColor in rgbColors)
{
int cmyk = Aspose.Imaging.CmykColorHelper.ToCmykIcc(rgbColor);
int c = Aspose.Imaging.CmykColorHelper.GetC(cmyk);
int m = Aspose.Imaging.CmykColorHelper.GetM(cmyk);
int y = Aspose.Imaging.CmykColorHelper.GetY(cmyk);
int k = Aspose.Imaging.CmykColorHelper.GetK(cmyk);
System.Console.WriteLine("RGB({0},{1},{2})\t\t=> CMYK({3},{4},{5},{6})", rgbColor.R, rgbColor.G, rgbColor.B, c, m, y, k);
}
// Specify your path to the RGB and CMYK ICC profiles.
string dir = "c:\\temp\\iccprofiles\\";
System.Console.WriteLine("Convert RGB to CMYK using custom ICC profiles.");
using (System.IO.Stream rgbProfileStream = System.IO.File.OpenRead(dir + "eciRGB_v2.icc"))
using (System.IO.Stream cmykProfileStream = System.IO.File.OpenRead(dir + "ISOcoated_v2_FullGamut4.icc"))
{
foreach (Aspose.Imaging.Color rgbColor in rgbColors)
{
int cmyk = Aspose.Imaging.CmykColorHelper.ToCmykIcc(rgbColor, rgbProfileStream, cmykProfileStream);
int c = Aspose.Imaging.CmykColorHelper.GetC(cmyk);
int m = Aspose.Imaging.CmykColorHelper.GetM(cmyk);
int y = Aspose.Imaging.CmykColorHelper.GetY(cmyk);
int k = Aspose.Imaging.CmykColorHelper.GetK(cmyk);
System.Console.WriteLine("RGB({0},{1},{2})\t\t=> CMYK({3},{4},{5},{6})", rgbColor.R, rgbColor.G, rgbColor.B, c, m, y, k);
}
}
//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(int, Stream, Stream)
The conversion from ARGB color to CMYK color using Icc conversion with custom profiles.
public static int ToCmykIcc(int argb, Stream rgbIccStream, Stream cmykIccStream)Parameters
argb int
The ARGB color.
rgbIccStream Stream
The stream containing RGB Icc profile.
cmykIccStream Stream
The stream containing CMYK Icc profile.
Returns
The CMYK color presented as a 32-bit integer value.
ToCmykIccBytes(int[], int, int, Stream, Stream)
Converts RGB to CMYK using custom ICC profiles.
public static byte[] ToCmykIccBytes(int[] pixels, int startIndex, int length, Stream rgbIccStream, Stream cmykIccStream)Parameters
pixels int
[]
The RGB colors presented as 32-bit integer values.
startIndex int
The start index of RGB color.
length int
The number of RGB pixels to convert.
rgbIccStream Stream
The RGB profile stream.
cmykIccStream Stream
The CMYK profile stream.
Returns
byte []
The CMYK colors presented as a byte array.
ToCmykaBytes(int[], int, int)
Converts ARGB to CMYKA (with transparency).
public static byte[] ToCmykaBytes(int[] argbPixels, int startIndex, int length)Parameters
argbPixels int
[]
The RGB colors presented as 32-bit integer values.
startIndex int
The start index of RGB color.
length int
The number of RGB pixels to convert.
Returns
byte []
The CMYK colors presented as a byte array.
ToCmykaIccBytes(int[], int, int, Stream, Stream)
Converts RGB to CMYKA (with alpha) using custom ICC profiles.
public static byte[] ToCmykaIccBytes(int[] pixels, int startIndex, int length, Stream rgbIccStream, Stream cmykIccStream)Parameters
pixels int
[]
The RGB colors presented as 32-bit integer values.
startIndex int
The start index of RGB color.
length int
The number of RGB pixels to convert.
rgbIccStream Stream
The RGB profile stream.
cmykIccStream Stream
The CMYK profile stream.
Returns
byte []
The CMYK colors presented as a byte array.
ToPsdCmykIcc(int[], Stream, Stream)
The conversion from ARGB colors to CMYK colors using Icc conversion with custom profiles. Uses PSD CMYK format KCMY byte order with inverted channel values.
public static int[] ToPsdCmykIcc(int[] pixels, Stream rgbIccStream, Stream cmykIccStream)Parameters
pixels int
[]
The ARGB colors.
rgbIccStream Stream
The stream containing RGB Icc profile.
cmykIccStream Stream
The stream containing CMYK Icc profile.
Returns
int []
The CMYK colors presented as 32-bit integer values in KCMY byte order with inverted channel values..
ToPsdCmykIcc(int[])
The conversion from ARGB colors to CMYK colors using Icc conversion with default profiles. Uses PSD CMYK format KCMY byte order with inverted channel values.
public static int[] ToPsdCmykIcc(int[] pixels)Parameters
pixels int
[]
The ARGB colors.
Returns
int []
The CMYK colors presented as 32-bit integer values in KCMY byte order with inverted channel values..
ToPsdCmykIcc(int)
The conversion from ARGB color to CMYK color using Icc conversion with default profiles. Uses PSD CMYK format KCMY byte order with inverted channel values.
public static int ToPsdCmykIcc(int argb)Parameters
argb int
The ARGB color.
Returns
The CMYK color presented as a 32-bit integer value in KCMY byte order with inverted channel values.
ToPsdCmykIcc(int, Stream, Stream)
The conversion from ARGB color to CMYK color using Icc conversion with custom profiles.
public static int ToPsdCmykIcc(int pixel, Stream rgbIccStream, Stream cmykIccStream)Parameters
pixel int
The ARGB color.
rgbIccStream Stream
The stream containing RGB Icc profile.
cmykIccStream Stream
The stream containing CMYK Icc profile.
Returns
The CMYK colors presented as 32-bit integer values in KCMY byte order with inverted channel values..