BitMiracle.LibJpeg.Classic.Internal.jpeg_d_post_controller.post_process_2pass C# (CSharp) Method

post_process_2pass() private method

Process some data in the second pass of 2-pass quantization.
private post_process_2pass ( byte output_buf, int &out_row_ctr, int out_rows_avail ) : void
output_buf byte
out_row_ctr int
out_rows_avail int
return void
        private void post_process_2pass(byte[][] output_buf, ref int out_row_ctr, int out_rows_avail)
        {
            int num_rows, max_rows;

            /* Reposition virtual buffer if at start of strip. */
            if (m_next_row == 0)
                m_buffer = m_whole_image.Access(m_starting_row, m_strip_height);

            /* Determine number of rows to emit. */
            num_rows = m_strip_height - m_next_row; /* available in strip */
            max_rows = out_rows_avail - out_row_ctr; /* available in output area */
            if (num_rows > max_rows)
                num_rows = max_rows;

            /* We have to check bottom of image here, can't depend on upsampler. */
            max_rows = m_cinfo.m_output_height - m_starting_row;
            if (num_rows > max_rows)
                num_rows = max_rows;

            /* Quantize and emit data. */
            m_cinfo.m_cquantize.color_quantize(m_buffer, m_next_row, output_buf, out_row_ctr, num_rows);
            out_row_ctr += num_rows;

            /* Advance if we filled the strip. */
            m_next_row += num_rows;
            if (m_next_row >= m_strip_height)
            {
                m_starting_row += m_strip_height;
                m_next_row = 0;
            }
        }
    }