示例#1
0
        /// <summary>
        /// Reads the compressed data from the djvu file
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="count"></param>
        /// <param name="compressedSectionLength"></param>
        private void ReadCompressedData(DjvuReader reader, int count, int compressedSectionLength)
        {
            DjvuReader decompressor = reader.GetBZZEncodedReader(compressedSectionLength);

            // Read the component sizes
            for (int x = 0; x < count; x++)
            {
                _components[x].Size = decompressor.ReadInt24MSB();
            }

            // Read the component flag information
            for (int x = 0; x < count; x++)
            {
                _components[x].DecodeFlags(decompressor.ReadSByte());
            }

            // Read the component strings
            for (int x = 0; x < count; x++)
            {
                _components[x].ID = decompressor.ReadNullTerminatedString();
                if (_components[x].HasName == true)
                {
                    _components[x].Name = decompressor.ReadNullTerminatedString();
                }
                if (_components[x].HasTitle == true)
                {
                    _components[x].Title = decompressor.ReadNullTerminatedString();
                }
            }

            _isInitialized = true;
        }
示例#2
0
        /// <summary>
        /// Reads in the bookmark data
        /// </summary>
        /// <returns></returns>
        private Bookmark[] ReadBookmarkData()
        {
            using (DjvuReader reader = Reader.CloneReader(_dataLocation))
            {
                DjvuReader decompressor = reader.GetBZZEncodedReader(Length);

                int totalBookmarks = decompressor.ReadUInt16MSB();

                List <Bookmark> bookmarks = new List <Bookmark>();

                // Read in all the bookmarks
                while (bookmarks.Count() + bookmarks.Sum(x => x.TotalBookmarks) != totalBookmarks)
                {
                    bookmarks.Add(new Bookmark(decompressor, Document, null));
                }

                return(bookmarks.ToArray());
            }
        }
示例#3
0
        /// <summary>
        /// Decodes the palette data
        /// </summary>
        /// <param name="reader"></param>
        private void ReadPaletteData(DjvuReader reader)
        {
            sbyte header       = reader.ReadSByte();
            bool  isShapeTable = (header >> 7) == 1;

            _version = header & 127;

            int paletteSize = reader.ReadInt16MSB();

            // Read in the palette colors
            List <Pixel> paletteColors = new List <Pixel>();

            for (int x = 0; x < paletteSize; x++)
            {
                sbyte b = reader.ReadSByte();
                sbyte g = reader.ReadSByte();
                sbyte r = reader.ReadSByte();

                paletteColors.Add(new Pixel(b, g, r));
            }
            _paletteColors = paletteColors.ToArray();

            if (isShapeTable == true)
            {
                int totalBlits = reader.ReadInt24MSB();

                DjvuReader compressed = reader.GetBZZEncodedReader();

                // Read in the blit colors
                List <int> blitColors = new List <int>();
                for (int x = 0; x < totalBlits; x++)
                {
                    int index = compressed.ReadInt16MSB();
                    blitColors.Add(index);
                }
                _blitColors = blitColors.ToArray();
            }
        }
示例#4
0
        /// <summary>
        /// Reads the compressed data from the djvu file
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="count"></param>
        /// <param name="compressedSectionLength"></param>
        private void ReadCompressedData(DjvuReader reader, int count, int compressedSectionLength)
        {
            DjvuReader decompressor = reader.GetBZZEncodedReader(compressedSectionLength);

            // Read the component sizes
            for (int x = 0; x < count; x++)
            {
                _components[x].Size = decompressor.ReadInt24MSB();
            }

            // Read the component flag information
            for (int x = 0; x < count; x++)
            {
                _components[x].DecodeFlags(decompressor.ReadSByte());
            }

            // Read the component strings
            for (int x = 0; x < count; x++)
            {
                _components[x].ID = decompressor.ReadNullTerminatedString();
                if (_components[x].HasName == true) _components[x].Name = decompressor.ReadNullTerminatedString();
                if (_components[x].HasTitle == true) _components[x].Title = decompressor.ReadNullTerminatedString();
            }

            _isInitialized = true;
        }
示例#5
0
        /// <summary>
        /// Decodes the palette data
        /// </summary>
        /// <param name="reader"></param>
        private void ReadPaletteData(DjvuReader reader)
        {
            sbyte header = reader.ReadSByte();
            bool isShapeTable = (header >> 7) == 1;
            _version = header & 127;

            int paletteSize = reader.ReadInt16MSB();

            // Read in the palette colors
            List<Pixel> paletteColors = new List<Pixel>();
            for (int x = 0; x < paletteSize; x++)
            {
                sbyte b = reader.ReadSByte();
                sbyte g = reader.ReadSByte();
                sbyte r = reader.ReadSByte();

                paletteColors.Add(new Pixel(b, g, r));
            }
            _paletteColors = paletteColors.ToArray();

            if (isShapeTable == true)
            {
                int totalBlits = reader.ReadInt24MSB();

                DjvuReader compressed = reader.GetBZZEncodedReader();

                // Read in the blit colors
                List<int> blitColors = new List<int>();
                for (int x = 0; x < totalBlits; x++)
                {
                    int index = compressed.ReadInt16MSB();
                    blitColors.Add(index);
                }
                _blitColors = blitColors.ToArray();
            }
        }