示例#1
0
        /// <summary>
        /// Decodes the children of this chunk
        /// </summary>
        /// <param name="reader"></param>
        private void ReadChildren(DjvuReader reader)
        {
            List <IFFChunk> children = new List <IFFChunk>();

            // Read in all the chunks
            while (reader.Position < Offset + Length + 8)
            {
                if (reader.Position % 2 == 1)
                {
                    reader.Position++;
                }

                // Read the chunk ID
                string     id   = reader.ReadUTF8String(4);
                ChunkTypes type = IFFChunk.GetChunkType(id);

                // Reset the stream position
                reader.Position -= 4;

                var chunk = IFFChunk.BuildIFFChunk(reader, Document, this, type);

                if (chunk != null)
                {
                    children.Add(chunk);
                }
            }

            Children = children.ToArray();
        }
示例#2
0
        /// <summary>
        /// Initializes the IFFChunk
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="parent"></param>
        public IFFChunk(DjvuReader reader, IFFChunk parent, DjvuDocument document)
        {
            _reader   = reader;
            _parent   = parent;
            _document = document;

            // Move back 4 to compensate for the chunk type already read
            _offset = reader.Position - 4;

            ReadChunkHeader(reader);
            ReadChunkData(reader);
        }
示例#3
0
        /// <summary>
        /// Gets all the children items of the given type
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="page"></param>
        /// <returns></returns>
        private T[] GetChildrenItems <T>(IFFChunk page) where T : IFFChunk
        {
            // Check if this is a thumbnail
            if (page is T)
            {
                return(new T[] { (T)page });
            }

            // No items if not form
            if (page is FormChunk == false)
            {
                return(new T[0]);
            }

            List <T>  results = new List <T>();
            FormChunk form    = (FormChunk)page;

            foreach (IFFChunk chunk in form.Children)
            {
                results.AddRange(GetChildrenItems <T>(chunk));
            }

            return(results.ToArray());
        }
示例#4
0
 public SmmrChunk(DjvuReader reader, IFFChunk parent, DjvuDocument document)
     : base(reader, parent, document)
 {
 }
示例#5
0
 public FormChunk(DjvuReader reader, IFFChunk parent, DjvuDocument document)
     : base(reader, parent, document)
 {
     // Nothing
 }
示例#6
0
        /// <summary>
        /// Builds the appropriate chunk for the ID
        /// </summary>
        /// <returns></returns>
        public static IFFChunk BuildIFFChunk(DjvuReader reader, DjvuDocument rootDocument, IFFChunk parent, ChunkTypes chunkType)
        {
            IFFChunk result = null;

            if (chunkType == ChunkTypes.Form)
            {
                result = new FormChunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.Form_Djvm)
            {
                result = new DjvmChunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.Form_Djvu)
            {
                result = new DjvuChunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.Form_Djvi)
            {
                result = new DjviChunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.Form_Thum)
            {
                result = new ThumChunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.Dirm)
            {
                result = new DirmChunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.Navm)
            {
                result = new NavmChunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.Anta)
            {
                result = new AntaChunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.Antz)
            {
                result = new AntzChunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.Txta)
            {
                result = new TxtaChunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.Txtz)
            {
                result = new TxtzChunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.Djbz)
            {
                result = new DjbzChunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.Sjbz)
            {
                result = new SjbzChunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.FG44)
            {
                result = new FG44Chunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.BG44)
            {
                result = new BG44Chunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.TH44)
            {
                result = new TH44Chunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.WMRM)
            {
                result = new WmrmChunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.FGbz)
            {
                result = new FGbzChunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.Info)
            {
                result = new InfoChunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.Incl)
            {
                result = new InclChunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.BGjp)
            {
                result = new BGjpChunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.FGjp)
            {
                result = new FGjpChunk(reader, parent, rootDocument);
            }
            else if (chunkType == ChunkTypes.Smmr)
            {
                result = new SmmrChunk(reader, parent, rootDocument);
            }
            else
            {
                result = new UnknownChunk(reader, parent, rootDocument);
            }

            //Console.WriteLine(result);
            return(result);
        }