CSharp examples for System.Drawing:Color Convert
Converts CMYK to RGB
using System.Drawing; using System;/*from w w w.ja v a 2 s . c o m*/ public class Main{ /// <summary> /// Converts CMYK to RGB /// </summary> /// <param name="_cmyk">A color to convert</param> /// <returns>A Color object</returns> public static Color CMYK_to_RGB(CMYK _cmyk) { int red, green, blue; red = Round(255 - (255 * _cmyk.C)); green = Round(255 - (255 * _cmyk.M)); blue = Round(255 - (255 * _cmyk.Y)); return Color.FromArgb(red, green, blue); } /// <summary> /// Custom rounding function. /// </summary> /// <param name="val">Value to round</param> /// <returns>Rounded value</returns> private static int Round(double val) { int ret_val = (int)val; int temp = (int)(val * 100); if ( (temp % 100) >= 50 ) ret_val += 1; return ret_val; } }