예제 #1
0
        private static HuffmanTable[] getHTables(JHUFF_TBL[] jpegHuffmanTables, HuffmanTable.EnumComponent comp)
        {
            int hCount = jpegHuffmanTables.Length;

            HuffmanTable[] ht        = new HuffmanTable[hCount];
            BindingFlags   bindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;
            int            idx       = 0;

            while (null != jpegHuffmanTables[idx])
            {
                ht[idx].Component = comp;
                Type      type     = jpegHuffmanTables[idx].GetType();
                object    instance = jpegHuffmanTables[idx];
                FieldInfo field    = type.GetField("m_bits", bindFlags);
                var       obj      = field.GetValue(instance);
                ht[idx].Bits    = field.GetValue(instance) as byte[];
                field           = type.GetField("m_huffval", bindFlags);
                ht[idx].Huffval = field.GetValue(instance) as byte[];
                ++idx;
            }
            var hTables = ht.Where(tab => null != tab.Bits).ToArray();

            return(hTables);
        }