title: Faster method of changing an image hue?
body: <p>Is there a better method to change the hue of an image smoothly as I slide through a trackbar? What I'm doing is getting the RGB value per pixel, calculating the saturation and brightness then putting the values in.  The size of the image affects the speed the hue is updated.  Photoshop's image hue function changes the hue from 0 to 360 smoothly which is what I want to try and get to.</p>
  
  <pre><code>data = editImage.LockBits(new Rectangle(0, 0, editWidth, editHeight), 
  ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
  byte* dataPtr = (byte*)data.Scan0;
  h = trackBar1.Value / 60.0;
  D = 1 - Math.Abs((h % 2) - 1);
  
  if (h &gt;= 0 &amp;&amp; h &lt; 1)
  {
      for (int i = 0; i &lt; editHeight; i++)
      {
          offsetStride = i * data.Stride;
          for (int j = 0; j &lt; editWidth; j++)
          {
              blue = dataPtr[(j * 3) + offsetStride];
              green = dataPtr[(j * 3) + offsetStride + 1];
              red = dataPtr[(j * 3) + offsetStride + 2];
  
              if (green &gt; blue) max = green;
              else max = blue;
              if (red &gt; max) max = red;
  
              if (green &lt; blue) min = green;
              else min = blue;
              if (red &lt; min) min = red;
  
              s = (max == 0) ? 0 : 1d - (1d * min / max);
              v = max / 255d;
  
              C = v * s;
              X = C * D;
              E = v - C;
  
              dataPtr[(j * 3) + offsetStride] = (byte)(min);
              dataPtr[(j * 3) + offsetStride + 1] = (byte)((X + E) * 255);
              dataPtr[(j * 3) + offsetStride + 2] = (byte)(max);
          }
      }
  }
  </code></pre>