public my_1pass_cquantizer(jpeg_decompress_struct cinfo)
{
m_cinfo = cinfo;
m_fserrors[0] = null; /* Flag FS workspace not allocated */
m_odither[0] = null; /* Also flag odither arrays not allocated */
/* Make sure my internal arrays won't overflow */
if (cinfo.m_out_color_components > MAX_Q_COMPS)
cinfo.ERREXIT(J_MESSAGE_CODE.JERR_QUANT_COMPONENTS, MAX_Q_COMPS);
/* Make sure colormap indexes can be represented by JSAMPLEs */
if (cinfo.m_desired_number_of_colors > (JpegConstants.MAXJSAMPLE + 1))
cinfo.ERREXIT(J_MESSAGE_CODE.JERR_QUANT_MANY_COLORS, JpegConstants.MAXJSAMPLE + 1);
/* Create the colormap and color index table. */
create_colormap();
create_colorindex();
/* Allocate Floyd-Steinberg workspace now if requested.
* We do this now since it is FAR storage and may affect the memory
* manager's space calculations. If the user changes to FS dither
* mode in a later pass, we will allocate the space then, and will
* possibly overrun the max_memory_to_use setting.
*/
if (cinfo.m_dither_mode == J_DITHER_MODE.JDITHER_FS)
alloc_fs_workspace();
}