public int RGBtoV(byte r, byte g, byte b)
 {
     int delta;
     int v;
     byte temp = Math.Max(r, g);
     byte max = Math.Max(b, temp);
     byte min;
     temp = Math.Min(r, g);
     min = Math.Min(temp, b);
     v = max;
     return v;
 }
        public int RGBtoH(byte r, byte g, byte b)
        {
            int delta;
            int h;
            byte temp = Math.Max(r, g);
            byte max = Math.Max(b, temp);
            byte min;
            temp = Math.Min(r, g);
            min = Math.Min(temp, b);

            delta = max - min;
            if (max != 0)
            {

            }
            else
            {
                return -1;
            }
            if (r == max)
            {
                h = (g - b) / delta;		// between yellow & magenta
            }
            else if (g == max)
            {
                h = 2 + (b - r) / delta;	// between cyan & yellow
            }
            else
            {
                h = 4 + (r - g) / delta;	// between magenta & cyan
            }
            h *= 60;				// degrees
            if (h < 0)
            {
                h += 360;
            }
            return h;
        }