Esempio n. 1
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;
        }
Esempio n. 2
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;
        }
Esempio n. 3
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);
        }
Esempio n. 4
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();
        }