Base class for all codecs within the library.

A codec is a class that implements decoding, encoding, or decoding and encoding of a compression algorithm.

The library provides a collection of builtin codecs. More codecs may be registered through calls to the library and/or the builtin implementations may be overridden.

Example #1
0
        /// <summary>
        /// Compression schemes statically built into the library.
        /// </summary>
        private void setupBuiltInCodecs()
        {
            // change initial syntax of m_builtInCodecs, maintains easier.
            // San Chen <*****@*****.**>

            m_builtInCodecs = new TiffCodec[]
            {
                new TiffCodec(this, (Compression)(-1), "Not configured"),
                new DumpModeCodec(this, Compression.NONE, "None"),
                new LZWCodec(this, Compression.LZW, "LZW"),
                new PackBitsCodec(this, Compression.PACKBITS, "PackBits"),
                new TiffCodec(this, Compression.THUNDERSCAN, "ThunderScan"),
                new TiffCodec(this, Compression.NEXT, "NeXT"),
                new JpegCodec(this, Compression.JPEG, "JPEG"),
                new OJpegCodec(this, Compression.OJPEG, "Old-style JPEG"),
                new CCITTCodec(this, Compression.CCITTRLE, "CCITT RLE"),
                new CCITTCodec(this, Compression.CCITTRLEW, "CCITT RLE/W"),
                new CCITTCodec(this, Compression.CCITTFAX3, "CCITT Group 3"),
                new CCITTCodec(this, Compression.CCITTFAX4, "CCITT Group 4"),
                new TiffCodec(this, Compression.JBIG, "ISO JBIG"),
                new DeflateCodec(this, Compression.DEFLATE, "Deflate"),
                new DeflateCodec(this, Compression.ADOBE_DEFLATE, "AdobeDeflate"),
                new TiffCodec(this, Compression.PIXARLOG, "PixarLog"),
                new TiffCodec(this, Compression.SGILOG, "SGILog"),
                new TiffCodec(this, Compression.SGILOG24, "SGILog24"),
                null,
            };
        }
Example #2
0
        /// <summary>
        /// Compression schemes statically built into the library.
        /// </summary>
        private void setupBuiltInCodecs()
        {
            // change initial syntax of m_builtInCodecs, maintains easier.
            // San Chen <*****@*****.**>

            m_builtInCodecs = new TiffCodec[]
            {
                new TiffCodec(this, (Compression)(-1), "Not configured"),
                new DumpModeCodec(this, Compression.NONE, "None"),
                new LZWCodec(this, Compression.LZW, "LZW"),
                new PackBitsCodec(this, Compression.PACKBITS, "PackBits"),
                new TiffCodec(this, Compression.THUNDERSCAN, "ThunderScan"),
                new TiffCodec(this, Compression.NEXT, "NeXT"),
                new JpegCodec(this, Compression.JPEG, "JPEG"),
                new OJpegCodec(this, Compression.OJPEG, "Old-style JPEG"),
                new CCITTCodec(this, Compression.CCITTRLE, "CCITT RLE"),
                new CCITTCodec(this, Compression.CCITTRLEW, "CCITT RLE/W"),
                new CCITTCodec(this, Compression.CCITTFAX3, "CCITT Group 3"),
                new CCITTCodec(this, Compression.CCITTFAX4, "CCITT Group 4"),
                new TiffCodec(this, Compression.JBIG, "ISO JBIG"),
                new DeflateCodec(this, Compression.DEFLATE, "Deflate"),
                new DeflateCodec(this, Compression.ADOBE_DEFLATE, "AdobeDeflate"),
                new TiffCodec(this, Compression.PIXARLOG, "PixarLog"),
                new TiffCodec(this, Compression.SGILOG, "SGILog"),
                new TiffCodec(this, Compression.SGILOG24, "SGILog24"),
                null,
            };
        }
Example #3
0
        internal bool setCompressionScheme(Compression scheme)
        {
            TiffCodec c = FindCodec(scheme);

            if (c == null)
            {
                /*
                 * Don't treat an unknown compression scheme as an error.
                 * This permits applications to open files with data that
                 * the library does not have builtin support for, but which
                 * may still be meaningful.
                 */
                c = m_builtInCodecs[0];
            }

            m_decodestatus = c.CanDecode;
            m_flags       &= ~(TiffFlags.NOBITREV | TiffFlags.NOREADRAW);

            m_currentCodec = c;
            return(c.Init());
        }
Example #4
0
        /// <summary>
        /// Retrieves an array of configured codecs, both built-in and registered by user.
        /// </summary>
        /// <returns>An array of configured codecs.</returns>
        public TiffCodec[] GetConfiguredCodecs()
        {
            int totalCodecs = 0;
            for (int i = 0; m_builtInCodecs[i] != null; i++)
            {
                if (m_builtInCodecs[i] != null && IsCodecConfigured(m_builtInCodecs[i].m_scheme))
                    totalCodecs++;
            }

            for (codecList cd = m_registeredCodecs; cd != null; cd = cd.next)
                totalCodecs++;

            TiffCodec[] codecs = new TiffCodec[totalCodecs];

            int codecPos = 0;
            for (codecList cd = m_registeredCodecs; cd != null; cd = cd.next)
                codecs[codecPos++] = cd.codec;

            for (int i = 0; m_builtInCodecs[i] != null; i++)
            {
                if (m_builtInCodecs[i] != null && IsCodecConfigured(m_builtInCodecs[i].m_scheme))
                    codecs[codecPos++] = m_builtInCodecs[i];
            }

            return codecs;
        }
Example #5
0
        /// <summary>
        /// Removes specified codec from a list of registered codecs.
        /// </summary>
        /// <param name="codec">The codec to remove from a list of registered codecs.</param>
        public void UnRegisterCodec(TiffCodec codec)
        {
            if (m_registeredCodecs == null)
                return;

            codecList temp;
            if (m_registeredCodecs.codec == codec)
            {
                temp = m_registeredCodecs.next;
                m_registeredCodecs = temp;
                return;
            }

            for (codecList list = m_registeredCodecs; list != null; list = list.next)
            {
                if (list.next != null)
                {
                    if (list.next.codec == codec)
                    {
                        temp = list.next.next;
                        list.next = temp;
                        return;
                    }
                }
            }

            ErrorExt(this, 0, "UnRegisterCodec",
                "Cannot remove compression scheme {0}; not registered", codec.m_name);
        }
Example #6
0
        /// <summary>
        /// Adds specified codec to a list of registered codec.
        /// </summary>
        /// <param name="codec">The codec to register.</param>
        /// <remarks>
        /// This method can be used to augment or override the set of codecs available to an
        /// application. If the <paramref name="codec"/> is for a scheme that already has a
        /// registered codec then it is overridden and any images with data encoded with this
        /// compression scheme will be decoded using the supplied codec.
        /// </remarks>
        public void RegisterCodec(TiffCodec codec)
        {
            if (codec == null)
                throw new ArgumentNullException("codec");

            codecList list = new codecList();
            list.codec = codec;
            list.next = m_registeredCodecs;
            m_registeredCodecs = list;
        }