I\'m looking for an algorithm to convert an RGB color to CMYK. Photoshop is performing the conversion below:
R = 220 G = 233 B = 174
C = 15 M = 0 Y = 40 K =
For convert RGB to CMYK you can use ColorHelper library.
using ColorHelper;
RGB rgb = new RGB(220, 234, 174);
CMYK cmyk = ColorConverter.RgbToCmyk(rgb);
Conversion algorithm in this library:
public static CMYK RgbToCmyk(RGB rgb)
{
double modifiedR, modifiedG, modifiedB, c, m, y, k;
modifiedR = rgb.R / 255.0;
modifiedG = rgb.G / 255.0;
modifiedB = rgb.B / 255.0;
k = 1 - new List() { modifiedR, modifiedG, modifiedB }.Max();
c = (1 - modifiedR - k) / (1 - k);
m = (1 - modifiedG - k) / (1 - k);
y = (1 - modifiedB - k) / (1 - k);
return new CMYK(
(byte)Math.Round(c * 100),
(byte)Math.Round(m * 100),
(byte)Math.Round(y * 100),
(byte)Math.Round(k * 100));
}
Link - https://github.com/iamartyom/ColorHelper/blob/master/ColorHelper/Converter/ColorConverter.cs