title: Capture desktop , Make it 256 color and send it over internet
body: <p>I am working on a project and in this project I need to capture desktop screen and send it over internet to other client. To compress the image I want to convert it to a 256 color image. I have a general 256 color palette and I am using Euclidean distance to find the nearest color. The problem is that I need to send these images in 10-15 frames per second and making a 256 color image takes 7 seconds. I am wondering how other programs (like teamviewer or real VNC ) are doing this.</p>
  
  <pre><code>for (int y=0;y&lt;900;y++) //loop through the height
       for (int x=0;x&lt;1600;x++) //loop through the width
           for (int p=0;p&lt;256;p++) //loop through palette colors
               {
                  calculate Euclidean distance of each pixel for each color in pallette and 
                   find the nearest color
                   ** these nested loops take 7 seconds to complete
               }
  </code></pre>
  
  <p>Thanks</p>