如何在indesign中以编程方式将CMYK转换为RGB [英] How to convert CMYK to RGB programmatically in indesign
问题描述
我在indesign中有一个CMYK色彩空间,我想将其转换为RGB色彩空间,我有一些代码,但我得到的数据不正确。
I have a CMYK colorspace in indesign, i want to convert that as RGB color space, I got some codes, but I am getting incorrect data.
我试过的代码如下:
double cyan = 35.0;
double magenta = 29.0;
double yellow = 0.0;
double black = 16.0;
cyan = Math.min(255, cyan + black); //black is from K
magenta = Math.min(255, magenta + black);
yellow = Math.min(255, yellow + black);
l_res[0] = 255 - cyan;
l_res[1] = 255 - magenta;
l_res[2] = 255 - yellow;
@Override
public float[] toRGB(float[] p_colorvalue) {
float[] l_res = {0,0,0};
if (p_colorvalue.length >= 4)
{
float l_black = (float)1.0 - p_colorvalue[3];
l_res[0] = l_black * ((float)1.0 - p_colorvalue[0]);
l_res[1] = l_black * ((float)1.0 - p_colorvalue[1]);
l_res[2] = l_black * ((float)1.0 - p_colorvalue[2]);
}
return (l_res);
}
值为C = 35,M = 29,Y = 0,K在CMYK颜色空间中= 16,正确的RGB值是R = 142,G = 148,B = 186。
The values are C=35, M = 29, Y = 0, K = 16 in CMYK color space and the correct RGB values are R = 142, G = 148, B = 186.
在adobe indesign中,使用色板我们可以更改模式到CMYK或RGB。
In adobe indesign, using swatches we can change the mode to CMYK or to RGB.
但是我想以编程方式进行,我可以使用任何算法将CMYK转换为RGB,这将给出正确的RGB值。
But I want to do that programmatically, Can I get any algorithm to convert CMYK to RGB which will give the correct RGB values.
还有一个问题,如果RGB的alpha值是1,那么CMYK的alpha值是多少?
And one more question, if the alpha value for RGB is 1 then what will be the alpha value for CMYK?
任何人都可以帮我解决这些问题......提前致谢。
Can anyone help me to solve these issues... Thanks in advance.
推荐答案
回答你的上一个问题:
如果RGB颜色空间中的alpha为1,则在CMYK颜色空间中为1。这两个空格只是指定颜色,而不是透明度。
If the alpha is 1 in RGB colour space it will be 1 in CMYK colour space to. Both spaces are just specifying the colours, not the transparency.
在你的CMYK到RGB转换问题上,你应该注意到
On your CMYK to RGB conversion problem, you should note that
CMYK和RGB模型之间没有确切的转换 - 两个颜色空间都覆盖不同的颜色色域
还讨论了这个维基百科页面
这篇关于如何在indesign中以编程方式将CMYK转换为RGB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!