Skip to main content
Inspiring
August 10, 2010
Question

Conversion between CMYK percent and actual value

  • August 10, 2010
  • 1 reply
  • 5073 views

Hello,

I'm using AISwatchListSuite to get the RGB and CMYK color definations of the swatches.

result = sAISwatchList->GetAIColor(swatch, &swatchColor) gives the AIColor reference

float

c = swatchColor.c.f.cyan;

float m = swatchColor.c.f.magenta;

float y = swatchColor.c.f.yellow;

float k = swatchColor.c.f.black;

For example, a color with C=46.67%, M=47.06%, Y=0%, K=0%.

The values returned through swatchColor are:

c=0.5804, m=0.5373, y=0.9294, k=100.00.

How to convert these values to actual percent?

Thanks and Best regards,

Hitesh

This topic has been closed for replies.

1 reply

A. Patterson
Inspiring
August 10, 2010

Are you sure you're comparing the right colour to the right %? CMYK are all 0.0-1.0 values, so they should be straight up conversions, no real math required (other than multiplying by 100). Unless I'm missing something, it is early here

Hitz_MAuthor
Inspiring
August 10, 2010

The color mode for the swatch is RGB.

So i added code to get RGB values:

float

c = swatchColor.c.f.cyan;

float m = swatchColor.c.f.magenta;

float y = swatchColor.c.f.yellow;

float k = swatchColor.c.f.black;

float r = swatchColor.c.rgb.red;

float g = swatchColor.c.rgb.green;

float b = swatchColor.c.rgb.blue;

comaring the values, c = r, m = g, y = b. by multiplying rgb with 255, i get the correct values for rgb.

Changed the color mode to CMYK, i get the correct values of cmyk. But again c=r, m=g, y=b, now the RGB values are incorrect.

Also the % is (1 - c) * 100.

Thanks,

Hitesh

A. Patterson
Inspiring
August 10, 2010

That sounds like the quick & dirty method of RGB -> CMYK. You should try using the AIColorConversionSuite and see if that works any better. That's what AI uses to convert, and I know its more complicated than what you desribed.