简体   繁体   中英

TranslateColors() color range of RGB and CMYK

I am using the API TranslateColors() to convert RGB to CYMK. I could convert it.

http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.gdi/2007-10/msg00049.html

In the above sample RGB value is left shifted by 8 and passed to the above function. And the result, CYMK is right shifted by 8.

As I know CYMK values vary from 0 to 1. But the result are more than 1.

Can any one tell me how to get the CYMK values in 0-1.

RGB values are between the range 0-255 to get this range between 0-1 you will need to do:

ic[0].rgb.red = (255.0 / 255.0) << 8 ;
ic[0].rgb.green = (0 / 255.0);
ic[0].rgb.blue = (0 / 255.0);

basically

value = value / max_range_of_value;

make sure the variables used are floats or decimals (or anything that supports decimals).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM