예제 #1
0
        public void ProgressiveDecodeBackground_Theory(string file, long length)
        {
            using (FileStream fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
                using (IDjvuReader reader = new DjvuReader(fs))
                {
                    BG44Chunk unk = new BG44Chunk(reader, null, null, "BG44", length);
                    unk.Initialize();
                    var map    = new InterWavePixelMapDecoder();
                    var result = unk.ProgressiveDecodeBackground(map);
                    Assert.Same(result, map);
#if !_APPVEYOR
                    string dumpsDir = Path.Combine(Util.ArtifactsDataPath, "dumps");
                    if (!System.IO.Directory.Exists(dumpsDir))
                    {
                        System.IO.Directory.CreateDirectory(dumpsDir);
                    }
                    using (System.Drawing.Bitmap image = map.GetPixelMap().ToImage())
                    {
                        string fileName = Path.GetFileNameWithoutExtension(file);
                        string outFile  = Path.Combine(dumpsDir, fileName + "_bg44.png");
                        using (FileStream stream = new FileStream(outFile, FileMode.Create))
                            image.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                    }
#endif
                }
        }
예제 #2
0
        public void ImageTest035()
        {
            string file = Path.Combine(Util.ArtifactsDataPath, "test035C_P01_0.bg44");

            using (FileStream fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
                using (IDjvuReader reader = new DjvuReader(fs))
                {
                    BG44Chunk unk = new BG44Chunk(reader, null, null, "BG44", fs.Length);
                    unk.Initialize();
                    var map = new InterWavePixelMapDecoder();
                    IInterWavePixelMap result = unk.BackgroundImage;
                    var pixMap = result.GetPixelMap();
                    unk.BackgroundImage = map;
                    Assert.NotSame(result, unk.BackgroundImage);
                    Assert.Same(map, unk.BackgroundImage);
                }
        }