Codecs that want to support the Predictor tag should inherit from this class instead of TiffCodec. Such codecs should not override default TiffCodec's methods for decode|encode setup and encoding|decoding of row|tile|strip. Codecs with predictor support should override equivalent methods provided by this class. If codec wants to provide custom tag get|set|print methods, then it should pass pointer to a object derived from TiffTagMethods as parameter to TIFFPredictorInit
Inheritance: TiffCodec
Beispiel #1
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);
            }
        }
Beispiel #2
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));
        }
Beispiel #3
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));
        }