public int jpeg_write_raw_data(byte[][][] data, int num_lines)
{
if (m_global_state != JpegState.CSTATE_RAW_OK)
ERREXIT(J_MESSAGE_CODE.JERR_BAD_STATE, (int)m_global_state);
if (m_next_scanline >= m_image_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_next_scanline;
m_progress.Pass_limit = m_image_height;
m_progress.Updated();
}
/* Give master control module another chance if this is first call to
* jpeg_write_raw_data. This lets output of the frame/scan headers be
* delayed so that application can write COM, etc, markers between
* jpeg_start_compress and jpeg_write_raw_data.
*/
if (m_master.MustCallPassStartup())
m_master.pass_startup();
/* Verify that at least one iMCU row has been passed. */
int lines_per_iMCU_row = m_max_v_samp_factor * min_DCT_v_scaled_size;
if (num_lines < lines_per_iMCU_row)
ERREXIT(J_MESSAGE_CODE.JERR_BUFFER_SIZE);
/* Directly compress the row. */
if (!m_coef.compress_data(data))
{
/* If compressor did not consume the whole row, suspend processing. */
return 0;
}
/* OK, we processed one iMCU row. */
m_next_scanline += lines_per_iMCU_row;
return lines_per_iMCU_row;
}