/// <summary> /// Base constructor. /// </summary> /// <param name="errorManager">The error manager.</param> /// <seealso cref="jpeg_compress_struct"/> /// <seealso cref="jpeg_decompress_struct"/> public jpeg_common_struct(jpeg_error_mgr errorManager) { Err = errorManager; }
/// <summary> /// Initializes a new instance of the <see cref="jpeg_compress_struct"/> class. /// </summary> /// <param name="errorManager">The error manager.</param> public jpeg_compress_struct(jpeg_error_mgr errorManager) : base(errorManager) { initialize(); }
/// <summary> /// Base constructor. /// </summary> /// <param name="errorManager">The error manager.</param> /// <seealso cref="jpeg_compress_struct"/> /// <seealso cref="jpeg_decompress_struct"/> protected jpeg_common_struct(jpeg_error_mgr errorManager) { Err = errorManager; }
private void cleanState() { m_compression = null; m_decompression = null; m_common = null; m_h_sampling = 0; m_v_sampling = 0; m_jpegtables = null; m_jpegtables_length = 0; m_jpegquality = 0; m_jpegcolormode = 0; m_jpegtablesmode = 0; m_ycbcrsampling_fetched = false; m_recvparams = 0; m_subaddress = null; m_recvtime = 0; m_faxdcs = null; m_rawDecode = false; m_rawEncode = false; m_cinfo_initialized = false; m_err = null; m_photometric = 0; m_bytesperline = 0; m_ds_buffer = new byte[JpegConstants.MAX_COMPONENTS][][]; m_scancount = 0; m_samplesperclump = 0; }
public override bool Init() { Debug.Assert(m_scheme == Compression.JPEG); /* * Merge codec-specific tag information and override parent get/set * field methods. */ m_tif.MergeFieldInfo(jpegFieldInfo, jpegFieldInfo.Length); /* * Allocate state block so tag methods have storage to record values. */ cleanState(); m_err = new JpegErrorManager(this); m_parentTagMethods = m_tif.m_tagmethods; m_tif.m_tagmethods = m_tagMethods; /* Default values for codec-specific fields */ m_jpegquality = 75; /* Default IJG quality */ m_jpegcolormode = JpegColorMode.RGB; m_jpegtablesmode = JpegTablesMode.QUANT | JpegTablesMode.HUFF; m_tif.m_flags |= TiffFlags.NOBITREV; // no bit reversal, please /* ** Create a JPEGTables field if no directory has yet been created. ** We do this just to ensure that sufficient space is reserved for ** the JPEGTables field. It will be properly created the right ** size later. */ if (m_tif.m_diroff == 0) { const int SIZE_OF_JPEGTABLES = 2000; // The following line assumes incorrectly that all JPEG-in-TIFF // files will have a JPEGTABLES tag generated and causes // null-filled JPEGTABLES tags to be written when the JPEG data // is placed with WriteRawStrip. The field bit should be // set, anyway, later when actual JPEGTABLES header is // generated, so removing it here hopefully is harmless. // // m_tif.setFieldBit(FIELD_JPEGTABLES); // m_jpegtables_length = SIZE_OF_JPEGTABLES; m_jpegtables = new byte[m_jpegtables_length]; } /* * Mark the YCBCRSAMPLES as present even if it is not * see: JPEGFixupTestSubsampling(). */ m_tif.setFieldBit(FieldBit.YCbCrSubsampling); return true; }
private void cleanState() { m_jpeg_interchange_format = 0; m_jpeg_interchange_format_length = 0; m_jpeg_proc = 0; m_subsamplingcorrect_done = false; m_subsampling_tag = false; m_subsampling_hor = 0; m_subsampling_ver = 0; m_qtable_offset_count = 0; m_dctable_offset_count = 0; m_actable_offset_count = 0; m_qtable_offset = new uint[3]; m_dctable_offset = new uint[3]; m_actable_offset = new uint[3]; m_restart_interval = 0; m_libjpeg_jpeg_decompress_struct = null; m_file_size = 0; m_image_width = 0; m_image_length = 0; m_strile_width = 0; m_strile_length = 0; m_strile_length_total = 0; m_samples_per_pixel = 0; m_plane_sample_offset = 0; m_samples_per_pixel_per_plane = 0; m_subsamplingcorrect = false; m_subsampling_force_desubsampling_inside_decompression = false; m_qtable = new byte[4][]; m_dctable = new byte[4][]; m_actable = new byte[4][]; m_restart_index = 0; m_sof_log = false; m_sof_marker_id = 0; m_sof_x = 0; m_sof_y = 0; m_sof_c = new byte[3]; m_sof_hv = new byte[3]; m_sof_tq = new byte[3]; m_sos_cs = new byte[3]; m_sos_tda = new byte[3]; m_sos_end = new SosEnd[3]; m_readheader_done = false; m_writeheader_done = false; m_write_cursample = 0; m_write_curstrile = 0; m_libjpeg_session_active = false; m_libjpeg_jpeg_query_style = 0; m_libjpeg_jpeg_error_mgr = null; m_libjpeg_jpeg_source_mgr = null; m_subsampling_convert_log = false; m_subsampling_convert_ylinelen = 0; m_subsampling_convert_ylines = 0; m_subsampling_convert_clinelen = 0; m_subsampling_convert_clines = 0; m_subsampling_convert_ybuf = null; m_subsampling_convert_cbbuf = null; m_subsampling_convert_crbuf = null; m_subsampling_convert_ycbcrimage = null; m_subsampling_convert_clinelenout = 0; m_subsampling_convert_state = 0; m_bytes_per_line = 0; m_lines_per_strile = 0; m_in_buffer_source = OJPEGStateInBufferSource.osibsNotSetYet; m_in_buffer_next_strile = 0; m_in_buffer_strile_count = 0; m_in_buffer_file_pos = 0; m_in_buffer_file_pos_log = false; m_in_buffer_file_togo = 0; m_in_buffer_togo = 0; m_in_buffer_cur = 0; // index into m_in_buffer m_in_buffer = new byte[OJPEG_BUFFER]; m_out_state = 0; m_out_buffer = new byte[OJPEG_BUFFER]; m_skip_buffer = null; m_forceProcessedRgbOutput = false; }
private bool OJPEGWriteHeaderInfo() { Debug.Assert(!m_libjpeg_session_active); m_out_state = OJPEGStateOutState.ososSoi; m_restart_index = 0; m_libjpeg_jpeg_error_mgr = new OJpegErrorManager(this); if (!jpeg_create_decompress_encap()) return false; m_libjpeg_session_active = true; m_libjpeg_jpeg_source_mgr = new OJpegSrcManager(this); m_libjpeg_jpeg_decompress_struct.Src = m_libjpeg_jpeg_source_mgr; if (jpeg_read_header_encap(true) == ReadResult.JPEG_SUSPENDED) return false; if (!m_subsampling_force_desubsampling_inside_decompression && (m_samples_per_pixel_per_plane > 1)) { m_libjpeg_jpeg_decompress_struct.Raw_data_out = true; m_libjpeg_jpeg_decompress_struct.Do_fancy_upsampling = false; //#if JPEG_LIB_VERSION >= 70 // libjpeg_jpeg_decompress_struct.do_fancy_upsampling=FALSE; //#endif m_libjpeg_jpeg_query_style = 0; if (!m_subsampling_convert_log) { Debug.Assert(m_subsampling_convert_ybuf == null); Debug.Assert(m_subsampling_convert_cbbuf == null); Debug.Assert(m_subsampling_convert_crbuf == null); Debug.Assert(m_subsampling_convert_ycbcrimage == null); m_subsampling_convert_ylinelen = (uint)((m_strile_width + m_subsampling_hor * 8 - 1) / (m_subsampling_hor * 8) * m_subsampling_hor * 8); m_subsampling_convert_ylines = (uint)(m_subsampling_ver * 8); m_subsampling_convert_clinelen = m_subsampling_convert_ylinelen / m_subsampling_hor; m_subsampling_convert_clines = 8; m_subsampling_convert_ybuf = new byte[m_subsampling_convert_ylines][]; for (int i = 0; i < m_subsampling_convert_ylines; i++) m_subsampling_convert_ybuf[i] = new byte[m_subsampling_convert_ylinelen]; m_subsampling_convert_cbbuf = new byte[m_subsampling_convert_clines][]; m_subsampling_convert_crbuf = new byte[m_subsampling_convert_clines][]; for (int i = 0; i < m_subsampling_convert_clines; i++) { m_subsampling_convert_cbbuf[i] = new byte[m_subsampling_convert_clinelen]; m_subsampling_convert_crbuf[i] = new byte[m_subsampling_convert_clinelen]; } m_subsampling_convert_ycbcrimage = new byte[3][][]; m_subsampling_convert_ycbcrimage[0] = new byte[m_subsampling_convert_ylines][]; for (uint n = 0; n < m_subsampling_convert_ylines; n++) m_subsampling_convert_ycbcrimage[0][n] = m_subsampling_convert_ybuf[n]; m_subsampling_convert_ycbcrimage[1] = new byte[m_subsampling_convert_clines][]; for (uint n = 0; n < m_subsampling_convert_clines; n++) m_subsampling_convert_ycbcrimage[1][n] = m_subsampling_convert_cbbuf[n]; m_subsampling_convert_ycbcrimage[2] = new byte[m_subsampling_convert_clines][]; for (uint n = 0; n < m_subsampling_convert_clines; n++) m_subsampling_convert_ycbcrimage[2][n] = m_subsampling_convert_crbuf[n]; m_subsampling_convert_clinelenout = ((m_strile_width + m_subsampling_hor - 1) / m_subsampling_hor); m_subsampling_convert_state = 0; m_bytes_per_line = (uint)(m_subsampling_convert_clinelenout * (m_subsampling_ver * m_subsampling_hor + 2)); m_lines_per_strile = ((m_strile_length + m_subsampling_ver - 1) / m_subsampling_ver); m_subsampling_convert_log = true; } } else { if (m_forceProcessedRgbOutput) { m_libjpeg_jpeg_decompress_struct.Do_fancy_upsampling = false; m_libjpeg_jpeg_decompress_struct.Jpeg_color_space = J_COLOR_SPACE.JCS_YCbCr; m_libjpeg_jpeg_decompress_struct.Out_color_space = J_COLOR_SPACE.JCS_RGB; } else { m_libjpeg_jpeg_decompress_struct.Jpeg_color_space = J_COLOR_SPACE.JCS_UNKNOWN; m_libjpeg_jpeg_decompress_struct.Out_color_space = J_COLOR_SPACE.JCS_UNKNOWN; } m_libjpeg_jpeg_query_style = 1; m_bytes_per_line = m_samples_per_pixel_per_plane * m_strile_width; m_lines_per_strile = m_strile_length; } if (!jpeg_start_decompress_encap()) return false; m_writeheader_done = true; return true; }