Esempio n. 1
0
        /// <summary>
        /// Emit a SOF marker
        /// </summary>
        private void emit_sof(JPEG_MARKER code)
        {
            emit_marker(code);

            emit_2bytes(3 * m_cinfo.m_num_components + 2 + 5 + 1); /* length */

            /* Make sure image isn't bigger than SOF field can handle */
            if (m_cinfo.m_image_height > 65535 || m_cinfo.m_image_width > 65535)
                m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_IMAGE_TOO_BIG, 65535);

            emit_byte(m_cinfo.m_data_precision);
            emit_2bytes(m_cinfo.m_image_height);
            emit_2bytes(m_cinfo.m_image_width);

            emit_byte(m_cinfo.m_num_components);

            for (int ci = 0; ci < m_cinfo.m_num_components; ci++)
            {
                jpeg_component_info componentInfo = m_cinfo.Component_info[ci];
                emit_byte(componentInfo.Component_id);
                emit_byte((componentInfo.H_samp_factor << 4) + componentInfo.V_samp_factor);
                emit_byte(componentInfo.Quant_tbl_no);
            }
        }
Esempio n. 2
0
		// Emit a SOF marker
		static void emit_sof(jpeg_compress cinfo, JPEG_MARKER code)
		{
			emit_marker(cinfo, code);

			emit_2bytes(cinfo, 3*cinfo.num_components+2+5+1); // length

			// Make sure image isn't bigger than SOF field can handle
			if(cinfo.image_height>65535||cinfo.image_width>65535) ERREXIT1(cinfo, J_MESSAGE_CODE.JERR_IMAGE_TOO_BIG, 65535);

			emit_byte(cinfo, cinfo.data_precision);
			emit_2bytes(cinfo, (int)cinfo.image_height);
			emit_2bytes(cinfo, (int)cinfo.image_width);

			emit_byte(cinfo, cinfo.num_components);

			for(int ci=0; ci<cinfo.num_components; ci++)
			{
				emit_byte(cinfo, cinfo.comp_info[ci].component_id);
				emit_byte(cinfo, (cinfo.comp_info[ci].h_samp_factor<<4)+cinfo.comp_info[ci].v_samp_factor);
				emit_byte(cinfo, cinfo.comp_info[ci].quant_tbl_no);
			}
		}
Esempio n. 3
0
 //////////////////////////////////////////////////////////////////////////
 // Basic output routines.
 //
 // Note that we do not support suspension while writing a marker.
 // Therefore, an application using suspension must ensure that there is
 // enough buffer space for the initial markers (typ. 600-700 bytes) before
 // calling jpeg_start_compress, and enough space to write the trailing EOI
 // (a few bytes) before calling jpeg_finish_compress.  Multipass compression
 // modes are not supported at all with suspension, so those two are the only
 // points where markers will be written.
 /// <summary>
 /// Emit a marker code
 /// </summary>
 private void emit_marker(JPEG_MARKER mark)
 {
     emit_byte(0xFF);
     emit_byte((int)mark);
 }
Esempio n. 4
0
		// Emit a marker code
		static void emit_marker(jpeg_compress cinfo, JPEG_MARKER mark)
		{
			emit_byte(cinfo, 0xFF);
			emit_byte(cinfo, (int)mark);
		}