title: Programatically step through 24 bit color spectrum, get x amount of average colors
body: <p>Yes, I AM trying to re-invent the wheel. :-) . I am doing my own image compression, (testing some ideas for transmitting parts of images over tcp). Anyway... I am trying to step through 24 bit rgb color, get a complete linear range, and (step through) that range at x intervals.</p>
  
  <p>I am trying to get the average 99 colors over the complete spectrum. (24bit / 99) = 167488.6363636364 , so at 16K interval I want to pic a color for my 99 color palette.</p>
  
  <p>I am having trouble understanding how RGB really works... It seems the is NO linear range..., or is there...?</p>
  
  <p>I am currently doing the following:</p>
  
  <pre><code>var_interval = (255 * 255 * 255) / 99
  
   For r = 0 To 255
       For g = 0 To 255
            For b = 0 To 255
  
                      If var_counter = var_interval Then
                      objWriter.Write(r &amp; "," &amp; g &amp; "," &amp; b)
  
                      End If
  
                      var_counter += 1
             Next
       Next
   Next
  </code></pre>
  
  <p>I am getting my colors, but this step does not generate "scaling" colors if you will.</p>
  
  <p>Any ideas?</p>