CMYK To RGB

This algorithm converts CMYK color model to RGB color model.



									class CMYK
{
	public $C;
	public $M;
	public $Y;
	public $K;
}

class RGB
{
	public $R;
	public $G;
	public $B;
}

function CMYKToRGB($cmyk) {
	$rgb = new RGB();

	$rgb->R = floor(255 * (1 - $cmyk->C) * (1 - $cmyk->K));
	$rgb->G = floor(255 * (1 - $cmyk->M) * (1 - $cmyk->K));
	$rgb->B = floor(255 * (1 - $cmyk->Y) * (1 - $cmyk->K));

	return $rgb;
}
								


Example

									$data = new CMYK();
$data->C = 0.47;
$data->M = 1;
$data->Y = 0.44;
$data->K = 0.39;

$rgb = CMYKToRGB($data);
								


Output

									R: 82
G: 0
B: 87