this question seems posted at many places over the interwebs and SO, but I could not find a satisfactory answer :(
How can I convert a RGB value to a CMYK value using an ICC profile?
The closest answer I have is there, where it explains how to convert from CMYK to RGB but not the other way around, which is what I need. (http://stackoverflow.com/questions/4920482/cmyk-to-rgb-formula-of-photoshop/5076731#5076731)
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);
I guess I should be using some classes/structures/methods from the System.Windows.Media namespace.
The System.Windows.Media.Color structure contains a method FromRgb, but I can't get CMYK values after, out of that System.Windows.Media.Color!
Many thanks
According to an MVP GDI+ can read CMYK but can't encode it (Source: http://www.pcreview.co.uk/forums/convert-rgb-image-cmyk-t1419911.html). They go on to say that using TIF as an intermediation format may be the way to go.
Other than that, you might try Graphics Mill imaging SDK for .NET at http://imaging.aurigma.com/ (I'm not affiliated with this company).
I know this isn't much of an answer, but hopefully it sheds some light and points you in the right direction.
None of the answers here seem to satisfactorily address the need to use an ICC profile.
I found an MS Connect issue page that has some sample code using Windows Imaging Components to convert an RBG JPEG to CMYK using an ICC profile.
If you have your ICC file and a sample JPEG file, you can set-up a console app to use this code very quickly.
I have saved the ICC profile in a folder called "Profiles" and have set the "Copy to Output Directory" value to "Always".
The JPEG is saved to a folder called "Images", and I have set its "Build Action" value to "Embedded Resource".
The console app project needs references to the following modules:
The console app in full (named CMYKConversion) :
Program.cs:
Converter.cs:
I don't know of any C# API or library that can achieve this. However, if you have enough C/C++ knowledge to build a wrapper for C#, I see two options:
The System.Windows.Media namespace is very limited. There's probably a powerful engine (WCS?) behind it, but just a small part is made available.
Update:
Here's some C# code to do the conversion using WCS. It certainly could use a wrapper that would make it easier to use:
You could have a look at this: Convert RGB color to CMYK?
Although this conversion is fairly subjective, hence the need for the ICC profile, it may be that you can extract that "factor" from the ICC and adjust the formula?
What is the context is which you need to convert the RGB values to CMYK?