CMYK To RGB

This algorithm converts CMYK color model to RGB color model.



									struct CMYK
{
	double C;
	double M;
	double Y;
	double K;
};

struct RGB
{
	unsigned char R;
	unsigned char G;
	unsigned char B;
};

struct RGB CMYKToRGB(struct CMYK cmyk) {
	struct RGB rgb;

	rgb.R = (unsigned char)(255 * (1 - cmyk.C) * (1 - cmyk.K));
	rgb.G = (unsigned char)(255 * (1 - cmyk.M) * (1 - cmyk.K));
	rgb.B = (unsigned char)(255 * (1 - cmyk.Y) * (1 - cmyk.K));

	return rgb;
}
								


Example

									struct CMYK data = { 0.47, 1, 0.44, 0.39 };
struct RGB value = CMYKToRGB(data);
								


Output

									R: 82
G: 0
B: 87