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. */ m_compression = null; m_decompression = null; m_photometric = 0; m_h_sampling = 0; m_v_sampling = 0; m_bytesperline = 0; m_scancount = 0; m_samplesperclump = 0; m_recvtime = 0; m_parentTagMethods = m_tif.m_tagmethods; m_tif.m_tagmethods = m_tagMethods; /* Default values for codec-specific fields */ m_jpegtables = null; m_jpegtables_length = 0; m_jpegquality = 75; /* Default IJG quality */ m_jpegcolormode = JpegColorMode.RGB; m_jpegtablesmode = JpegTablesMode.Quant | JpegTablesMode.Huff; m_recvparams = 0; m_subaddress = null; m_faxdcs = null; m_ycbcrsampling_fetched = false; m_rawDecode = false; m_rawEncode = false; m_tif.m_flags |= TiffFlags.NoBitRev; // no bit reversal, please m_cinfo_initialized = false; /* ** 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_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; }