BitMiracle.LibJpeg.Classic.Internal.my_2pass_cquantizer.select_colors C# (CSharp) Method

select_colors() private method

Master routine for color selection
private select_colors ( int desired_colors ) : void
desired_colors int
return void
        private void select_colors(int desired_colors)
        {
            /* Allocate workspace for box list */
            box[] boxlist = new box[desired_colors];

            /* Initialize one box containing whole space */
            int numboxes = 1;
            boxlist[0].c0min = 0;
            boxlist[0].c0max = JpegConstants.MAXJSAMPLE >> C0_SHIFT;
            boxlist[0].c1min = 0;
            boxlist[0].c1max = JpegConstants.MAXJSAMPLE >> C1_SHIFT;
            boxlist[0].c2min = 0;
            boxlist[0].c2max = JpegConstants.MAXJSAMPLE >> C2_SHIFT;

            /* Shrink it to actually-used volume and set its statistics */
            update_box(boxlist, 0);

            /* Perform median-cut to produce final box list */
            numboxes = median_cut(boxlist, numboxes, desired_colors);

            /* Compute the representative color for each box, fill colormap */
            for (int i = 0; i < numboxes; i++)
                compute_color(boxlist, i, i);

            m_cinfo.m_actual_number_of_colors = numboxes;
            m_cinfo.TRACEMS(1, J_MESSAGE_CODE.JTRC_QUANT_SELECTED, numboxes);
        }