コード例 #1
0
ファイル: SjbzChunk.cs プロジェクト: sahwar/DjvuNet
        internal JB2Image ReadCompressedImage()
        {
            using (IDjvuReader reader = Reader.CloneReaderToMemory(DataOffset, Length))
            {
                JB2Image          image = new JB2Image();
                JB2.JB2Dictionary includedDictionary = null;
                DjvuChunk         djvuChunk          = Parent as DjvuChunk;

                if (djvuChunk != null)
                {
                    var includes = djvuChunk.IncludedItems;

                    if (includes?.Count > 0)
                    {
                        string includeID = includes
                                           .FirstOrDefault <InclChunk>(x => x.ChunkType == ChunkType.Incl)?.IncludeID;
                        DjvmChunk     root      = Document.RootForm as DjvmChunk;
                        DirmComponent component = root?.Dirm.Components
                                                  .Where <DirmComponent>(x => x.ID == includeID).FirstOrDefault();

                        var includeForm =
                            root.Includes
                            .Where(x => x.DataOffset == (component.Offset + 12))
                            .FirstOrDefault <IDjviChunk>();

                        var djbzItem = includeForm?.Children
                                       .Where <IDjvuNode>(x => x.ChunkType == ChunkType.Djbz).FirstOrDefault() as DjbzChunk;

                        includedDictionary = djbzItem?.ShapeDictionary;
                    }
                }

                image.Decode(reader, includedDictionary);

                return(image);
            }
        }
コード例 #2
0
ファイル: IFFChunk.cs プロジェクト: dronab/DjvuNet
        /// <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);
        }