BitMiracle.LibJpeg.Classic.Internal.my_upsampler.int_upsample C# (CSharp) Method

int_upsample() private method

This version handles any integral sampling ratios. This is not used for typical JPEG files, so it need not be fast. Nor, for that matter, is it particularly accurate: the algorithm is simple replication of the input pixel onto the corresponding output pixels. The hi-falutin sampling literature refers to this as a "box filter". A box filter tends to introduce visible artifacts, so if you are actually going to use 3:1 or 4:1 sampling ratios you would be well advised to improve this code.
private int_upsample ( ComponentBuffer &input_data ) : void
input_data ComponentBuffer
return void
        private void int_upsample(ref ComponentBuffer input_data)
        {
            ComponentBuffer output_data = m_color_buf[m_currentComponent];
            int h_expand = m_h_expand[m_currentComponent];
            int v_expand = m_v_expand[m_currentComponent];

            int inrow = 0;
            int outrow = 0;
            while (outrow < m_cinfo.m_max_v_samp_factor)
            {
                /* Generate one output row with proper horizontal expansion */
                int row = m_upsampleRowOffset + inrow;
                for (int col = 0; col < m_cinfo.m_output_width; col++)
                {
                    byte invalue = input_data[row][col]; /* don't need GETJSAMPLE() here */
                    int outIndex = 0;
                    for (int h = h_expand; h > 0; h--)
                    {
                        output_data[outrow][outIndex] = invalue;
                        outIndex++;
                    }
                }
                
                /* Generate any additional output rows by duplicating the first one */
                if (v_expand > 1)
                {
                    JpegUtils.jcopy_sample_rows(output_data, outrow, output_data, 
                        outrow + 1, v_expand - 1, m_cinfo.m_output_width);
                }

                inrow++;
                outrow += v_expand;
            }
        }
    }