BitMiracle.LibJpeg.Classic.Internal.my_2pass_cquantizer.compute_color C# (CSharp) Метод

compute_color() приватный Метод

Compute representative color for a box, put it in colormap[icolor]
private compute_color ( box boxlist, int boxIndex, int icolor ) : void
boxlist box
boxIndex int
icolor int
Результат void
        private void compute_color(box[] boxlist, int boxIndex, int icolor)
        {
            /* Current algorithm: mean weighted by pixels (not colors) */
            /* Note it is important to get the rounding correct! */
            long total = 0;
            long c0total = 0;
            long c1total = 0;
            long c2total = 0;
            box curBox = boxlist[boxIndex];
            for (int c0 = curBox.c0min; c0 <= curBox.c0max; c0++)
            {
                for (int c1 = curBox.c1min; c1 <= curBox.c1max; c1++)
                {
                    int histogramIndex = c1 * HIST_C2_ELEMS + curBox.c2min;
                    for (int c2 = curBox.c2min; c2 <= curBox.c2max; c2++)
                    {
                        long count = m_histogram[c0][histogramIndex];
                        histogramIndex++;

                        if (count != 0)
                        {
                            total += count;
                            c0total += ((c0 << C0_SHIFT) + ((1 << C0_SHIFT) >> 1)) * count;
                            c1total += ((c1 << C1_SHIFT) + ((1 << C1_SHIFT) >> 1)) * count;
                            c2total += ((c2 << C2_SHIFT) + ((1 << C2_SHIFT) >> 1)) * count;
                        }
                    }
                }
            }

            m_cinfo.m_colormap[0][icolor] = (byte)((c0total + (total >> 1)) / total);
            m_cinfo.m_colormap[1][icolor] = (byte)((c1total + (total >> 1)) / total);
            m_cinfo.m_colormap[2][icolor] = (byte)((c2total + (total >> 1)) / total);
        }