BitMiracle.LibJpeg.Classic.Internal.jpeg_marker_reader.get_lse C# (CSharp) Method

get_lse() private method

Process an LSE marker
private get_lse ( ) : bool
return bool
        private bool get_lse()
        {
            if (!m_cinfo.m_marker.m_saw_SOF)
                m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_SOF_BEFORE, "LSE");

            if (m_cinfo.m_num_components < 3)
                m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_CONVERSION_NOTIMPL);

            int length;
            if (!m_cinfo.m_src.GetTwoBytes(out length))
                return false;

            if (length != 24)
                m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_BAD_LENGTH);

            int tmp;
            if (!m_cinfo.m_src.GetByte(out tmp))
                return false;

            if (tmp != 0x0D)
            {
                /* ID inverse transform specification */
                m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_UNKNOWN_MARKER, m_cinfo.m_unread_marker);
            }

            if (!m_cinfo.m_src.GetTwoBytes(out tmp))
                return false;

            if (tmp != JpegConstants.MAXJSAMPLE)
            {
                /* MAXTRANS */
                m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_CONVERSION_NOTIMPL);
            }

            if (!m_cinfo.m_src.GetByte(out tmp))
                return false;

            if (tmp != 3)
            {
                /* Nt=3 */
                m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_CONVERSION_NOTIMPL);
            }

            int cid;
            if (!m_cinfo.m_src.GetByte(out cid))
                return false;

            if (cid != m_cinfo.Comp_info[1].Component_id)
                m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_CONVERSION_NOTIMPL);

            if (!m_cinfo.m_src.GetByte(out cid))
                return false;

            if (cid != m_cinfo.Comp_info[0].Component_id)
                m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_CONVERSION_NOTIMPL);

            if (!m_cinfo.m_src.GetByte(out cid))
                return false;

            if (cid != m_cinfo.Comp_info[2].Component_id)
                m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_CONVERSION_NOTIMPL);

            if (!m_cinfo.m_src.GetByte(out tmp))
                return false;

            if (tmp != 0x80)
            {
                /* F1: CENTER1=1, NORM1=0 */
                m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_CONVERSION_NOTIMPL);
            }

            if (!m_cinfo.m_src.GetTwoBytes(out tmp))
                return false;

            if (tmp != 0)
            {
                /* A(1,1)=0 */
                m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_CONVERSION_NOTIMPL);
            }

            if (!m_cinfo.m_src.GetTwoBytes(out tmp))
                return false;

            if (tmp != 0)
            {
                /* A(1,2)=0 */
                m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_CONVERSION_NOTIMPL);
            }

            if (!m_cinfo.m_src.GetByte(out tmp))
                return false;

            if (tmp != 0)
            {
                /* F2: CENTER2=0, NORM2=0 */
                m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_CONVERSION_NOTIMPL);
            }

            if (!m_cinfo.m_src.GetTwoBytes(out tmp))
                return false;

            if (tmp != 1)
            {
                /* A(2,1)=1 */
                m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_CONVERSION_NOTIMPL);
            }

            if (!m_cinfo.m_src.GetTwoBytes(out tmp))
                return false;

            if (tmp != 0)
            {
                /* A(2,2)=0 */
                m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_CONVERSION_NOTIMPL);
            }

            if (!m_cinfo.m_src.GetByte(out tmp))
                return false;

            if (tmp != 0)
            {
                /* F3: CENTER3=0, NORM3=0 */
                m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_CONVERSION_NOTIMPL);
            }

            if (!m_cinfo.m_src.GetTwoBytes(out tmp))
                return false;

            if (tmp != 1)
            {
                /* A(3,1)=1 */
                m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_CONVERSION_NOTIMPL);
            }

            if (!m_cinfo.m_src.GetTwoBytes(out tmp))
                return false;

            if (tmp != 0)
            {
                /* A(3,2)=0 */
                m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_CONVERSION_NOTIMPL);
            }

            /* OK, valid transform that we can handle. */
            m_cinfo.color_transform = J_COLOR_TRANSFORM.JCT_SUBTRACT_GREEN;
            return true;
        }