CMYK 2 RGB Problem

僤鯓⒐⒋嵵緔 提交于 2019-12-14 04:25:31

问题


I have a problem with converting a CMYK Color to RGB. In the internet there is many formulas to convert it but for example when I convert CMYK (0,100,100,0) to RGB, it get value (255 0 0) but in Adobe Photoshop RGB value is (237,28,36) and I want this one. Is anybody know how to convert it with java or .NET?


回答1:


There are other questions asking the same thing:

  • https://stackoverflow.com/questions/tagged/rgb+cmyk
  • How to convert CMYK to RGB programmatically in indesign
  • Convert RGB color to CMYK?

The general gist of your problem is that Photoshop is applying a Color Profile where-as you are simply doing a direct conversion. Please see my answers to some of the other questions as I feel like I've answered this question to death.




回答2:


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.

There's a nice web site showing the CMYK to RGB color conversion with the color profile at work.

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




回答3:


if you want photoshop like cmyk conversion then use JDeli java image library ; there is a class called EnumeratedSpace which does the job for you;

please do not forget to bit mask because return values are rgb bytes




回答4:


ColorJizz can convert from RGB to CMYK and many other formats. There's a .NET version in there.



来源:https://stackoverflow.com/questions/2676693/cmyk-2-rgb-problem

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!