public void BuildPageImage003() { int pageCount = 0; using (DjvuDocument document = Util.GetTestDocument(3, out pageCount)) { Util.VerifyDjvuDocument(pageCount, document); IDjvuPage page = document.FirstPage; var testImagePath = Path.Combine(Util.RepoRoot, "artifacts", "data", "test003C.png"); DjvuImage djvuImage = page.Image as DjvuImage; using (var image = djvuImage.BuildImage()) using (Bitmap testImage = new Bitmap(testImagePath)) { Assert.NotNull(image); Assert.IsType <Bitmap>(image); Rectangle rect = new Rectangle(0, 0, image.Width, image.Height); BitmapData data = image.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb); BitmapData testData = testImage.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb); bool result = Util.CompareImages(data, testData); image.UnlockBits(data); testImage.UnlockBits(testData); //image.Save(Path.Combine(Util.RepoRoot, "artifacts", "data", "dumps", "test003CBuildPageImagen.png")); //Assert.True(result); } } }
public void BuildImage_Theory(int docNumber) { int pageCount = 0; using (DjvuDocument document = Util.GetTestDocument(docNumber, out pageCount)) { Util.VerifyDjvuDocument(pageCount, document); IDjvuPage page = document.FirstPage; var testImagePath = Path.Combine(Util.RepoRoot, "artifacts", "data", $"test{docNumber:00#}C.png"); DjvuImage djvuImage = page.Image as DjvuImage; using (Bitmap image = djvuImage.BuildImage()) using (Bitmap testImage = new Bitmap(testImagePath)) { Assert.NotNull(image); Assert.IsType <Bitmap>(image); bool result = Util.CompareImagesForBinarySimilarity(testImage, image, docNumber == 75 ? 0.1485 : 0.0585, true, $"Testing Djvu image: \t\ttest{docNumber:00#}C.png, "); #if DUMP_IMAGES DumpImage(docNumber, image, "Img"); #endif Assert.True(result, $"Test failed: "); } } }
public void BuildPageImage002i() { int pageCount = 0; using (DjvuDocument document = Util.GetTestDocument(2, out pageCount)) { Util.VerifyDjvuDocument(pageCount, document); var page = document.FirstPage; page.IsInverted = true; DjvuImage djvuImage = page.Image as DjvuImage; using (var image = djvuImage.BuildImage()) { Assert.NotNull(image); Assert.IsType <Bitmap>(image); //image.Save(Path.Combine(Util.RepoRoot, "artifacts", "data", "dumps", "test002CBuildPageImagen.png")); } } }
public void BuildImage002i() { int pageCount = 0; using (DjvuDocument document = Util.GetTestDocument(2, out pageCount)) { Util.VerifyDjvuDocument(pageCount, document); var page = document.FirstPage; page.IsInverted = true; DjvuImage djvuImage = page.Image as DjvuImage; using (var image = djvuImage.BuildImage()) { Assert.NotNull(image); Assert.IsType <Bitmap>(image); } } }
public void BuildPageImage075() { int pageCount = 0; using (DjvuDocument document = Util.GetTestDocument(75, out pageCount)) { Util.VerifyDjvuDocument(pageCount, document); IDjvuPage page = document.FirstPage; var testImagePath = Path.Combine(Util.RepoRoot, "artifacts", "data", "test075C.png"); DjvuImage djvuImage = page.Image as DjvuImage; using (Bitmap image = djvuImage.BuildImage()) using (Bitmap testImage = new Bitmap(testImagePath)) { Assert.NotNull(image); Assert.IsType <Bitmap>(image); bool result = Util.CompareImagesForBinarySimilarity(testImage, image, 0.15); Assert.True(result); } } }