public virtual void start_pass(bool is_pre_scan)
{
/* Install my colormap. */
m_cinfo.m_colormap = m_sv_colormap;
m_cinfo.m_actual_number_of_colors = m_sv_actual;
/* Initialize for desired dithering mode. */
switch (m_cinfo.m_dither_mode)
{
case J_DITHER_MODE.JDITHER_NONE:
if (m_cinfo.m_out_color_components == 3)
m_quantizer = QuantizerType.color_quantizer3;
else
m_quantizer = QuantizerType.color_quantizer;
break;
case J_DITHER_MODE.JDITHER_ORDERED:
if (m_cinfo.m_out_color_components == 3)
m_quantizer = QuantizerType.quantize3_ord_dither_quantizer;
else
m_quantizer = QuantizerType.quantize3_ord_dither_quantizer;
/* initialize state for ordered dither */
m_row_index = 0;
/* If user changed to ordered dither from another mode,
* we must recreate the color index table with padding.
* This will cost extra space, but probably isn't very likely.
*/
if (!m_is_padded)
create_colorindex();
/* Create ordered-dither tables if we didn't already. */
if (m_odither[0] == null)
create_odither_tables();
break;
case J_DITHER_MODE.JDITHER_FS:
m_quantizer = QuantizerType.quantize_fs_dither_quantizer;
/* initialize state for F-S dither */
m_on_odd_row = false;
/* Allocate Floyd-Steinberg workspace if didn't already. */
if (m_fserrors[0] == null)
alloc_fs_workspace();
/* Initialize the propagated errors to zero. */
int arraysize = m_cinfo.m_output_width + 2;
for (int i = 0; i < m_cinfo.m_out_color_components; i++)
Array.Clear(m_fserrors[i], 0, arraysize);
break;
default:
m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_NOT_COMPILED);
break;
}
}