调用:
Color c=...;
byte[] cmyk=RGBToCMY(c.R, c.G, c.B);
byte[] RGBToCMY(byte red, byte green, byte blue)//RGB转CMY
{
byte cyan = (byte)255 - red;
byte magenta = (byte)255- green;
byte yellow = (byte)255 - blue;
return CorrectCMYK(cyan, magenta, yellow, (byte)20);//修正值
}
byte[] CorrectCMYK(byte cyan, byte magenta, byte yellow, byte rep_v)//色彩修正
{
byte temp = Math.Min(Math.Min(cyan, magenta), yellow);
byte rep_k, rep_c, rep_m, rep_y;
if (temp != 0)
{
byte temp2 = (byte)((rep_v / 100.0) * temp+0.9);
rep_k = (byte)(temp2 / 255.0 * 100+0.9);
rep_c = (byte)((cyan - temp2) / 255.0 * 100+0.9);
rep_m = (byte)((magenta - temp2) / 255.0 * 100+0.9);
rep_y = (byte)((yellow - temp2) / 255.0 * 100+0.9);
}
else
{
rep_c = (byte)(cyan / 255.0 * 100+0.9);
rep_m = (byte)(magenta / 255.0 * 100+0.9);
rep_y = (byte)(yellow / 255.0 * 100+0.9);
rep_k = 0;
}
byte[] bt = new byte[4] { rep_c, rep_m, rep_y, rep_k };
return bt;
}