BitMiracle.LibJpeg.Classic.jpeg_decompress_struct.jpeg_read_raw_data C# (CSharp) Method

jpeg_read_raw_data() public method

Alternate entry point to read raw data.
Replaces jpeg_read_scanlines when reading raw downsampled data. Processes exactly one iMCU row per call, unless suspended.
public jpeg_read_raw_data ( byte data, int max_lines ) : int
data byte The raw data.
max_lines int The number of scanlines for reading.
return int
        public int jpeg_read_raw_data(byte[][][] data, int max_lines)
        {
            if (m_global_state != JpegState.DSTATE_RAW_OK)
                ERREXIT(J_MESSAGE_CODE.JERR_BAD_STATE, (int)m_global_state);

            if (m_output_scanline >= m_output_height)
            {
                WARNMS(J_MESSAGE_CODE.JWRN_TOO_MUCH_DATA);
                return 0;
            }

            /* Call progress monitor hook if present */
            if (m_progress != null)
            {
                m_progress.Pass_counter = m_output_scanline;
                m_progress.Pass_limit = m_output_height;
                m_progress.Updated();
            }

            /* Verify that at least one iMCU row can be returned. */
            int lines_per_iMCU_row = m_max_v_samp_factor * min_DCT_v_scaled_size;
            if (max_lines < lines_per_iMCU_row)
                ERREXIT(J_MESSAGE_CODE.JERR_BUFFER_SIZE);

            int componentCount = data.Length; // maybe we should use max_lines here
            ComponentBuffer[] cb = new ComponentBuffer[componentCount];
            for (int i = 0; i < componentCount; i++)
            {
                cb[i] = new ComponentBuffer();
                cb[i].SetBuffer(data[i], null, 0);
            }

            /* Decompress directly into user's buffer. */
            if (m_coef.decompress_data(cb) == ReadResult.JPEG_SUSPENDED)
            {
                /* suspension forced, can do nothing more */
                return 0;
            }

            /* OK, we processed one iMCU row. */
            m_output_scanline += lines_per_iMCU_row;
            return lines_per_iMCU_row;
        }