BitMiracle.LibJpeg.Classic.Internal.jpeg_marker_writer.emit_dac C# (CSharp) Method

emit_dac() private method

private emit_dac ( ) : void
return void
        private void emit_dac()
        {
            byte[] dc_in_use = new byte[JpegConstants.NUM_ARITH_TBLS];
            byte[] ac_in_use = new byte[JpegConstants.NUM_ARITH_TBLS];

            for (int i = 0; i < m_cinfo.m_comps_in_scan; i++)
            {
                jpeg_component_info compptr = m_cinfo.Component_info[m_cinfo.m_cur_comp_info[i]];
                /* DC needs no table for refinement scan */
                if (m_cinfo.m_Ss == 0 && m_cinfo.m_Ah == 0)
                    dc_in_use[compptr.Dc_tbl_no] = 1;

                /* AC needs no table when not present */
                if (m_cinfo.m_Se != 0)
                    ac_in_use[compptr.Ac_tbl_no] = 1;
            }

            int length = 0;
            for (int i = 0; i < JpegConstants.NUM_ARITH_TBLS; i++)
                length += dc_in_use[i] + ac_in_use[i];

            if (length != 0)
            {
                emit_marker(JPEG_MARKER.DAC);

                emit_2bytes(length * 2 + 2);

                for (int i = 0; i < JpegConstants.NUM_ARITH_TBLS; i++)
                {
                    if (dc_in_use[i] != 0)
                    {
                        emit_byte(i);
                        emit_byte(m_cinfo.arith_dc_L[i] + (m_cinfo.arith_dc_U[i] << 4));
                    }
                    if (ac_in_use[i] != 0)
                    {
                        emit_byte(i + 0x10);
                        emit_byte(m_cinfo.arith_ac_K[i]);
                    }
                }
            }
        }