/ Published in: C++
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
void RGBtoCMYK(float color[4]) { if (color[0]==0 && color[1]==0 && color[2]==0) { color[0] = 0; color[1] = 0; color[2] = 0; color[3] = 1.0; } else if (color[0]==1.0 && color[1]==1.0 && color[2]==1.0) { color[0] = 0; color[1] = 0; color[2] = 0; color[3] = 0; } else { color[0] = 1.0 - color[0]; color[1] = 1.0 - color[1]; color[2] = 1.0 - color[2]; float minK = MIN(color[0], MIN(color[1], color[2])); color[0] = (color[0] - minK) / (1.0 - minK); color[1] = (color[1] - minK) / (1.0 - minK); color[2] = (color[2] - minK) / (1.0 - minK); color[3] = minK; } } void CMYKtoRGB(float color[4]) { color[0] = 1.0 - (color[0] * (1.0 - color[3]) + color[3]); color[1] = 1.0 - (color[1] * (1.0 - color[3]) + color[3]); color[2] = 1.0 - (color[2] * (1.0 - color[3]) + color[3]); color[3] = 1.0; }