CSharp examples for System.Drawing:Color RGB
Rgb From Hsv
// Permission is hereby granted, free of charge, to any person obtaining a copy of this using System.Windows.Media; using System.Text; using System.Linq; using System.Collections.Generic; using System;//ww w . j a v a 2s . c o m public class Main{ // http://en.wikipedia.org/wiki/HSV_color_space public static void RgbFromHsv(double h, double s, double v, out double r, out double g, out double b) { h = h % 360; if (h < 0) h += 360; // C# '%' can return negative values, use real modulus instead int hi = (int)(h / 60) % 6; var f = h / 60 - (int)(h / 60); var p = v * (1 - s); var q = v * (1 - f * s); var t = v * (1 - (1 - f) * s); switch (hi) { case 0: r = v; g = t; b = p; break; case 1: r = q; g = v; b = p; break; case 2: r = p; g = v; b = t; break; case 3: r = p; g = q; b = v; break; case 4: r = t; g = p; b = v; break; default: r = v; g = p; b = q; break; } } }