/**
		 * Analyzes image colors and creates color map.
		 */

        protected void AnalyzePixels()
        {
            var len = pixels.Length;
            var nPix = len/3;
            indexedPixels = new byte[nPix];
            var nq = new NeuQuant(pixels, len, sample);
            // initialize quantizer
            colorTab = nq.Process(); // create reduced palette
            // convert map from BGR to RGB
//			for (int i = 0; i < colorTab.Length; i += 3) 
//			{
//				byte temp = colorTab[i];
//				colorTab[i] = colorTab[i + 2];
//				colorTab[i + 2] = temp;
//				usedEntry[i / 3] = false;
//			}
            // map image pixels to new palette
            var k = 0;
            for (var i = 0; i < nPix; i++)
            {
                var index =
                    nq.Map(pixels[k++] & 0xff,
                        pixels[k++] & 0xff,
                        pixels[k++] & 0xff);
                usedEntry[index] = true;
                indexedPixels[i] = (byte) index;
            }
            pixels = null;
            colorDepth = 8;
            palSize = 7;
            // get closest match to transparent color if specified
            if (transparent != Color.Empty)
            {
                transIndex = FindClosest(transparent);
            }
        }
 /**
  * Analyzes image colors and creates color map.
  */
 protected void AnalyzePixels()
 {
     var len = pixels.Length;
     var nPix = len/3;
     indexedPixels = new byte[nPix];
     var nq = new NeuQuant(pixels, len, sample);
     // initialize quantizer
     colorTab = nq.Process(); // create reduced palette
     // convert map from BGR to RGB
     //			for (int i = 0; i < colorTab.Length; i += 3)
     //			{
     //				byte temp = colorTab[i];
     //				colorTab[i] = colorTab[i + 2];
     //				colorTab[i + 2] = temp;
     //				usedEntry[i / 3] = false;
     //			}
     // map image pixels to new palette
     var k = 0;
     for (var i = 0; i < nPix; i++)
     {
         var index =
             nq.Map(pixels[k++] & 0xff,
                 pixels[k++] & 0xff,
                 pixels[k++] & 0xff);
         usedEntry[index] = true;
         indexedPixels[i] = (byte) index;
     }
     pixels = null;
     colorDepth = 8;
     palSize = 7;
     // get closest match to transparent color if specified
     if (transparent != Color.Empty)
     {
         transIndex = FindClosest(transparent);
     }
 }