Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        protected void AnalyzePixels()
        {
            int num  = this.pixels.Length;
            int num2 = num / 3;

            this.indexedPixels = new byte[num2];
            NeuQuant neuQuant = new NeuQuant(this.pixels, num, this.sample);

            this.colorTab = neuQuant.Process();
            int num3 = 0;

            for (int i = 0; i < num2; i++)
            {
                int num4 = neuQuant.Map((int)(this.pixels[num3++] & 255), (int)(this.pixels[num3++] & 255), (int)(this.pixels[num3++] & 255));
                this.usedEntry[num4]  = true;
                this.indexedPixels[i] = (byte)num4;
            }
            this.pixels     = null;
            this.colorDepth = 8;
            this.palSize    = 7;
            if (this.transparent != Color.Empty)
            {
                this.transIndex = this.FindClosest(this.transparent);
            }
        }
Ejemplo n.º 2
0
        /**
         * Analyzes image colors and creates color map.
         */

        protected void AnalyzePixels()
        {
            int len  = pixels.Length;
            int nPix = len / 3;

            indexedPixels = new byte[nPix];
            NeuQuant 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
            int k = 0;

            for (int i = 0; i < nPix; i++)
            {
                int 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);
            }
        }