Convert RGB color to CMYK?

前端 未结 7 1723
谎友^
谎友^ 2020-11-28 12:09

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 =

7条回答
  •  执念已碎
    2020-11-28 13:03

    If you want good result, you need to apply a color profile. In .NET, you can do it like that (assuming the the original CMYK components are in the range between 0 and 255):

    float[] colorValues = new float[4];
    colorValues[0] = c / 255f;
    colorValues[1] = m / 255f;
    colorValues[2] = y / 255f;
    colorValues[3] = k / 255f;
    
    System.Windows.Media.Color color = Color.FromValues(colorValues,
        new Uri(@"C:\Users\me\Documents\ISOcoated_v2_300_eci.icc"));
    System.Drawing.Color rgbColor = System.Drawing.Color.FromArgb(color.R, color.G, color.B);
    

    Note that two different Color classes from two different namespaces are used. And you probably need to add the PresentationCore DLL as a reference.

    The required color profile can be downloaded from the downloads section of eci.org. It's part of a bigger ZIP file containing several profiles. They explicitly recommend to use the ISO Coated v2 300% (ECI) profile.

    If you need to convert a complete image from CMYK to RGB, there are special classes for this in the same namespace.

提交回复
热议问题