Exemplo n.º 1
0
        // tagMethods can be null
        public void TIFFPredictorInit(TiffTagMethods tagMethods)
        {
            // Merge codec-specific tag information and override parent get/set field methods.
            m_tif.MergeFieldInfo(m_predictFieldInfo, m_predictFieldInfo.Length);
            m_childTagMethods  = tagMethods;
            m_parentTagMethods = m_tif.m_tagmethods;
            m_tif.m_tagmethods = m_tagMethods;

            m_predictor     = Predictor.NONE;       // default value
            m_predictorType = PredictorType.ptNone; // no predictor method
        }
Exemplo n.º 2
0
        public override void PrintDir(Tiff tif, Stream fd, TiffPrintFlags flags)
        {
            CodecWithPredictor sp = tif.m_currentCodec as CodecWithPredictor;

            Debug.Assert(sp != null);

            if (tif.fieldSet(CodecWithPredictor.FIELD_PREDICTOR))
            {
                Tiff.fprintf(fd, "  Predictor: ");
                Predictor predictor = sp.GetPredictorValue();
                switch (predictor)
                {
                case Predictor.NONE:
                    Tiff.fprintf(fd, "none ");
                    break;

                case Predictor.HORIZONTAL:
                    Tiff.fprintf(fd, "horizontal differencing ");
                    break;

                case Predictor.FLOATINGPOINT:
                    Tiff.fprintf(fd, "floating point predictor ");
                    break;
                }

                Tiff.fprintf(fd, "{0} (0x{1:x})\r\n", predictor, predictor);
            }

            TiffTagMethods childMethods = sp.GetChildTagMethods();

            if (childMethods != null)
            {
                childMethods.PrintDir(tif, fd, flags);
            }
            else
            {
                base.PrintDir(tif, fd, flags);
            }
        }
Exemplo n.º 3
0
        public override FieldValue[] GetField(Tiff tif, TiffTag tag)
        {
            CodecWithPredictor sp = tif.m_currentCodec as CodecWithPredictor;

            Debug.Assert(sp != null);

            switch (tag)
            {
            case TiffTag.PREDICTOR:
                FieldValue[] result = new FieldValue[1];
                result[0].Set(sp.GetPredictorValue());
                return(result);
            }

            TiffTagMethods childMethods = sp.GetChildTagMethods();

            if (childMethods != null)
            {
                return(childMethods.GetField(tif, tag));
            }

            return(base.GetField(tif, tag));
        }
Exemplo n.º 4
0
        public override bool SetField(Tiff tif, TiffTag tag, FieldValue[] ap)
        {
            CodecWithPredictor sp = tif.m_currentCodec as CodecWithPredictor;

            Debug.Assert(sp != null);

            switch (tag)
            {
            case TiffTag.PREDICTOR:
                sp.SetPredictorValue((Predictor)ap[0].ToByte());
                tif.setFieldBit(CodecWithPredictor.FIELD_PREDICTOR);
                tif.m_flags |= TiffFlags.DIRTYDIRECT;
                return(true);
            }

            TiffTagMethods childMethods = sp.GetChildTagMethods();

            if (childMethods != null)
            {
                return(childMethods.SetField(tif, tag, ap));
            }

            return(base.SetField(tif, tag, ap));
        }
Exemplo n.º 5
0
 public DeflateCodec(Tiff tif, Compression scheme, string name)
     : base(tif, scheme, name)
 {
     m_tagMethods = new DeflateCodecTagMethods();
 }
Exemplo n.º 6
0
        private int m_offset;   // current position in m_buffer

        public CCITTCodec(Tiff tif, Compression scheme, string name)
            : base(tif, scheme, name)
        {
            m_tagMethods = new CCITTCodecTagMethods();
        }
Exemplo n.º 7
0
        private void InitCCITTFax3()
        {
            /*
            * Merge codec-specific tag information and
            * override parent get/set field methods.
            */
            m_tif.MergeFieldInfo(m_faxFieldInfo, m_faxFieldInfo.Length);

            /*
             * Allocate state block so tag methods have storage to record values.
             */
            cleanState();
            m_rw_mode = m_tif.m_mode;

            m_parentTagMethods = m_tif.m_tagmethods;
            m_tif.m_tagmethods = m_tagMethods;
            
            m_groupoptions = 0;
            m_recvparams = 0;
            m_subaddress = null;
            m_faxdcs = null;

            if (m_rw_mode == Tiff.O_RDONLY)
            {
                // FIXME: improve for in place update
                m_tif.m_flags |= TiffFlags.NOBITREV;
                // decoder does bit reversal
            }

            m_runs = null;
            m_tif.SetField(TiffTag.FAXFILLFUNC, new Tiff.FaxFillFunc(fax3FillRuns));
            m_refline = null;

            m_decoder = Decoder.useFax3_1DDecoder;
            m_encodingFax4 = false;
        }
Exemplo n.º 8
0
        // tagMethods can be null
        public void TIFFPredictorInit(TiffTagMethods tagMethods)
        {
            // Merge codec-specific tag information and override parent get/set field methods.
            m_tif.MergeFieldInfo(m_predictFieldInfo, m_predictFieldInfo.Length);
            m_childTagMethods = tagMethods;
            m_parentTagMethods = m_tif.m_tagmethods;
            m_tif.m_tagmethods = m_tagMethods;

            m_predictor = Predictor.NONE; // default value
            m_predictorType = PredictorType.ptNone; // no predictor method
        }
Exemplo n.º 9
0
 public CodecWithPredictor(Tiff tif, Compression scheme, string name)
     : base(tif, scheme, name)
 {
     m_tagMethods = new CodecWithPredictorTagMethods();
 }
Exemplo n.º 10
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;
        }
Exemplo n.º 11
0
 public CodecWithPredictor(Tiff tif, Compression scheme, string name)
     : base(tif, scheme, name)
 {
     m_tagMethods = new CodecWithPredictorTagMethods();
 }
Exemplo n.º 12
0
        public override bool Init()
        {
            Debug.Assert(m_scheme == Compression.OJPEG);

            /*
             * Merge codec-specific tag information.
             */
            m_tif.MergeFieldInfo(ojpeg_field_info, ojpeg_field_info.Length);

            cleanState();
            m_jpeg_proc = 1;
            m_subsampling_hor = 2;
            m_subsampling_ver = 2;

            m_tif.SetField(TiffTag.YCBCRSUBSAMPLING, 2, 2);

            /* tif tag methods */
            m_parentTagMethods = m_tif.m_tagmethods;
            m_tif.m_tagmethods = m_tagMethods;

            /* Some OJPEG files don't have strip or tile offsets or bytecounts
             * tags. Some others do, but have totally meaningless or corrupt
             * values in these tags. In these cases, the JpegInterchangeFormat
             * stream is reliable. In any case, this decoder reads the
             * compressed data itself, from the most reliable locations, and
             * we need to notify encapsulating LibTiff not to read raw strips
             * or tiles for us.
             */
            m_tif.m_flags |= TiffFlags.NOREADRAW;
            return true;
        }