开发者

CMYK 2 RGB Problem

开发者 https://www.devze.com 2022-12-27 07:40 出处:网络
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 Adob

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?


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.


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.


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号