public void DjvuChunk_Theory(DjvuJsonDocument doc, int index) { int pageCount = 0; using (DjvuDocument document = DjvuNet.Tests.Util.GetTestDocument(index, out pageCount)) { DjvuNet.Tests.Util.VerifyDjvuDocument(pageCount, document); DjvuNet.Tests.Util.VerifyDjvuDocumentCtor(pageCount, document); if (pageCount <= 1) { Assert.IsNotType <DjvmChunk>(document.RootForm); Assert.IsType <DjvuChunk>(document.RootForm); DjvuChunk djvu = document.RootForm as DjvuChunk; Assert.NotNull(djvu); Assert.NotNull(djvu.Info); // TODO - Json deserialization is not supporting single page docs // data are sliced to fit into other format - need to fix } else { Assert.IsType <DjvmChunk>(document.RootForm); DjvmChunk djvm = document.RootForm as DjvmChunk; Assert.NotNull(djvm); Assert.NotNull(djvm.Pages); Assert.True(djvm.Pages.Count > 1); } } }
internal void AddPage(Queue <ITH44Chunk> thumbnails, DjvuChunk page) { ITH44Chunk thumbnail = thumbnails?.Count > 0 ? thumbnails.Dequeue() : null; DjvuPage newPage = new DjvuPage(_Pages.Count + 1, this, null, thumbnail, Includes, page); _Pages.Add(newPage); }
public void GetRootFormChildren001() { int pageCount = 0; using (DjvuDocument doc = Util.GetTestDocument(30, out pageCount)) { DjvuChunk form = doc.GetRootFormChildren <DjvuChunk>().FirstOrDefault(); Assert.NotNull(form); Assert.IsType <DjvuChunk>(form); } }
public void ExtractRawDataTest() { int pageCount = 0; using (DjvuDocument document = DjvuNet.Tests.Util.GetTestDocument(2, out pageCount)) { DjvuNet.Tests.Util.VerifyDjvuDocument(pageCount, document); IDjvuPage page = document.FirstPage; DjvuChunk form = page.PageForm as DjvuChunk; Assert.NotNull(form); var reader = form.ExtractRawData(); Assert.NotNull(reader); Assert.Equal(form.Length, reader.Length); } }
public void IncludesTest() { int pageCount = 0; using (DjvuDocument document = DjvuNet.Tests.Util.GetTestDocument(2, out pageCount)) { DjvuNet.Tests.Util.VerifyDjvuDocument(pageCount, document); IDjvuPage page = document.FirstPage; DjvuChunk form = page.PageForm as DjvuChunk; Assert.NotNull(form); var includes = form.Includes; Assert.NotNull(includes); Assert.Equal(1, includes.Count); } }
public static IDjvuNode CreateEncodedDjvuNode(IDjvuWriter writer, IDjvuElement parent, ChunkType chunkType, long length) { IDjvuNode result = null; switch (chunkType) { case ChunkType.Djvm: result = new DjvmChunk(writer, parent, length); break; case ChunkType.Djvu: result = new DjvuChunk(writer, parent, length); break; case ChunkType.Djvi: result = new DjviChunk(writer, parent, length); break; case ChunkType.Thum: result = new ThumChunk(writer, parent, length); break; case ChunkType.Dirm: result = new DirmChunk(writer, parent, length); break; case ChunkType.Navm: result = new NavmChunk(writer, parent, length); break; case ChunkType.Anta: result = new AntaChunk(writer, parent, length); break; case ChunkType.Antz: result = new AntzChunk(writer, parent, length); break; case ChunkType.Txta: result = new TxtaChunk(writer, parent, length); break; case ChunkType.Txtz: result = new TxtzChunk(writer, parent, length); break; case ChunkType.Djbz: result = new DjbzChunk(writer, parent, length); break; case ChunkType.Sjbz: result = new SjbzChunk(writer, parent, length); break; case ChunkType.FG44: result = new FG44Chunk(writer, parent, length); break; case ChunkType.BG44: result = new BG44Chunk(writer, parent, length); break; case ChunkType.TH44: result = new TH44Chunk(writer, parent, length); break; case ChunkType.BM44: result = new BM44Chunk(writer, parent, length); break; case ChunkType.BM44Form: result = new BM44Form(writer, parent, length); break; case ChunkType.PM44: result = new PM44Chunk(writer, parent, length); break; case ChunkType.PM44Form: result = new PM44Form(writer, parent, length); break; case ChunkType.Wmrm: result = new WmrmChunk(writer, parent, length); break; case ChunkType.FGbz: result = new FGbzChunk(writer, parent, length); break; case ChunkType.Info: result = new InfoChunk(writer, parent, length); break; case ChunkType.Incl: result = new InclChunk(writer, parent, length); break; case ChunkType.BGjp: result = new BGjpChunk(writer, parent, length); break; case ChunkType.FGjp: result = new FGjpChunk(writer, parent, length); break; case ChunkType.Smmr: result = new SmmrChunk(writer, parent, length); break; default: throw new DjvuInvalidOperationException($"Chunk type is not supported in encoding. ChunkType: {chunkType}"); } return(result); }
/// <summary> /// Builds the appropriate chunk for the ID /// </summary> /// <returns></returns> public static IDjvuNode CreateDecodedDjvuNode(IDjvuReader reader, IDjvuDocument rootDocument, IDjvuElement parent, ChunkType chunkType, string chunkID = "", long length = 0) { IDjvuNode result = null; switch (chunkType) { case ChunkType.Djvm: result = new DjvmChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Djvu: result = new DjvuChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Djvi: result = new DjviChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Thum: result = new ThumChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Dirm: result = new DirmChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Navm: result = new NavmChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Anta: result = new AntaChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Antz: result = new AntzChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Txta: result = new TxtaChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Txtz: result = new TxtzChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Djbz: result = new DjbzChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Sjbz: result = new SjbzChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.FG44: result = new FG44Chunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.BG44: result = new BG44Chunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.TH44: result = new TH44Chunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.BM44: result = new BM44Chunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.BM44Form: result = new BM44Form(reader, parent, rootDocument, chunkID, length); break; case ChunkType.PM44: result = new PM44Chunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.PM44Form: result = new PM44Form(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Wmrm: result = new WmrmChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.FGbz: result = new FGbzChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Info: result = new InfoChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Incl: result = new InclChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.BGjp: result = new BGjpChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.FGjp: result = new FGjpChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Smmr: result = new SmmrChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Cida: result = new CidaChunk(reader, parent, rootDocument, chunkID, length); break; default: result = new UnknownChunk(reader, parent, rootDocument, chunkID, length); break; } return(result); }