ScreenToGif.Encoding.NeuQuant.Inxbuild C# (CSharp) Méthode

Inxbuild() private méthode

Insertion sort of network and building of _netindex[0..255] (to do after unbias).
private Inxbuild ( ) : void
Résultat void
        private void Inxbuild()
        {
            int j;

            var previouscol = 0;
            var startpos = 0;

            for (int i = 0; i < Netsize; i++)
            {
                int[] p = _network[i];
                int smallpos = i;
                int smallval = p[1];

                #region Find Smallest in i..netsize-1

                int[] q;
                for (int b = i + 1; b < Netsize; b++)
                {
                    q = _network[b];

                    if (q[1] < smallval)
                    {
                        /* index on g */
                        smallpos = b;
                        smallval = q[1]; /* index on g */
                    }
                }

                #endregion

                q = _network[smallpos];

                #region Swap p (i) and q (smallpos) entries.

                if (i != smallpos)
                {
                    j = q[0];
                    q[0] = p[0];
                    p[0] = j;

                    j = q[1];
                    q[1] = p[1];
                    p[1] = j;

                    j = q[2];
                    q[2] = p[2];
                    p[2] = j;

                    j = q[3];
                    q[3] = p[3];
                    p[3] = j;
                }

                #endregion

                //smallval entry is now in position i.
                if (smallval != previouscol)
                {
                    _netIndex[previouscol] = (startpos + i) >> 1;
                    for (j = previouscol + 1; j < smallval; j++)
                        _netIndex[j] = i;
                    previouscol = smallval;
                    startpos = i;
                }
            }

            _netIndex[previouscol] = (startpos + Maxnetpos) >> 1;

            for (j = previouscol + 1; j < 256; j++)
                _netIndex[j] = Maxnetpos; //Really 256.
        }