BitMiracle.LibJpeg.Classic.Internal.jpeg_d_main_controller.set_bottom_pointers C# (CSharp) Method

set_bottom_pointers() private method

Change the pointer lists to duplicate the last sample row at the bottom of the image. m_whichFunny indicates which m_funnyIndices holds the final iMCU row. Also sets rowgroups_avail to indicate number of nondummy row groups in row.
private set_bottom_pointers ( ) : void
return void
        private void set_bottom_pointers()
        {
            for (int ci = 0; ci < m_cinfo.m_num_components; ci++)
            {
                /* Count sample rows in one iMCU row and in one row group */
                int iMCUheight = m_cinfo.Comp_info[ci].V_samp_factor * m_cinfo.Comp_info[ci].DCT_v_scaled_size;
                int rgroup = iMCUheight / m_cinfo.min_DCT_v_scaled_size;

                /* Count nondummy sample rows remaining for this component */
                int rows_left = m_cinfo.Comp_info[ci].downsampled_height % iMCUheight;
                if (rows_left == 0)
                    rows_left = iMCUheight;

                /* Count nondummy row groups.  Should get same answer for each component,
                 * so we need only do it once.
                 */
                if (ci == 0)
                    m_rowgroups_avail = (rows_left - 1) / rgroup + 1;

                /* Duplicate the last real sample row rgroup*2 times; this pads out the
                 * last partial rowgroup and ensures at least one full rowgroup of context.
                 */
                for (int i = 0; i < rgroup * 2; i++)
                    m_funnyIndices[m_whichFunny][ci][rows_left + i + rgroup] = m_funnyIndices[m_whichFunny][ci][rows_left - 1 + rgroup];
            }
        }
    }