public void CloseCodecTest()
        {
            string file = Path.Combine(Util.ArtifactsDataPath, "test002C_P01_0.bg44");

            using (FileStream stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                using (DjvuReader reader = new DjvuReader(stream))
                {
                    var map = new InterWavePixelMapDecoder();
                    map.Decode(reader);
                    Assert.NotNull(map._YMap);
                    Assert.NotNull(map._YDecoder);
                    Assert.NotNull(map._CbMap);
                    Assert.NotNull(map._CbDecoder);
                    Assert.NotNull(map._CrMap);
                    Assert.NotNull(map._CrDecoder);

                    map.CloseCodec();
                    Assert.NotNull(map._YMap);
                    Assert.Null(map._YDecoder);
                    Assert.NotNull(map._CbMap);
                    Assert.Null(map._CbDecoder);
                    Assert.NotNull(map._CrMap);
                    Assert.Null(map._CrDecoder);
                }
        }
Beispiel #2
0
 /// <summary>
 /// Decodes the background image for this chunk
 /// </summary>
 /// <returns></returns>
 internal IInterWavePixelMap DecodeImage()
 {
     using (IDjvuReader reader = Reader.CloneReaderToMemory(DataOffset, Length))
     {
         IInterWavePixelMap pixelMap = new InterWavePixelMapDecoder();
         pixelMap.Decode(reader);
         return(pixelMap);
     }
 }
 public void DecodeTest004()
 {
     byte[] buffer = new byte[] { 0x01, 0x48, 0x01, 0x05, 0x03, 0x3B, 0x04, 0x3F, 0x8A, 0xFF, 0xFF, 0xE9, 0xFB, 0x80, 0x3E, 0xA2 };
     using (MemoryStream stream = new MemoryStream(buffer))
         using (DjvuReader reader = new DjvuReader(stream))
         {
             var map = new InterWavePixelMapDecoder();
             Assert.Throws <DjvuFormatException>(() => map.Decode(reader));
         }
 }
Beispiel #4
0
        /// <summary>
        /// Decodes the background image for this chunk
        /// </summary>
        /// <returns></returns>
        internal IInterWavePixelMap DecodeBackgroundImage()
        {
            using (IDjvuReader reader = Reader.CloneReaderToMemory(DataOffset, Length))
            {
                IInterWavePixelMap background = new InterWavePixelMapDecoder();
                background.Decode(reader);

                return(background);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Decodes the thumbnail image for this chunk
        /// </summary>
        /// <returns></returns>
        internal IInterWavePixelMap DecodeThumbnailImage()
        {
            using (IDjvuReader reader = Reader.CloneReaderToMemory(DataOffset, Length))
            {
                IInterWavePixelMap thumbnail = new InterWavePixelMapDecoder();
                thumbnail.Decode(reader);

                return(thumbnail);
            }
        }
Beispiel #6
0
        public void DuplicateTest001()
        {
            string file = Path.Combine(Util.ArtifactsDataPath, "test002C_P01_0.bg44");

            using (FileStream stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                using (DjvuReader reader = new DjvuReader(stream))
                {
                    var map = new InterWavePixelMapDecoder();
                    map.Decode(reader);
                    Assert.NotNull(map._YMap);
                    Assert.NotNull(map._YDecoder);
                    Assert.NotNull(map._CbMap);
                    Assert.NotNull(map._CbDecoder);
                    Assert.NotNull(map._CrMap);
                    Assert.NotNull(map._CrDecoder);

                    var dyMap = map._YMap.Duplicate();
                    Assert.NotNull(dyMap);
                    Assert.Equal(map._YMap.Width, dyMap.Width);
                    Assert.Equal(map._YMap.Height, dyMap.Height);
                    Assert.Equal(map._YMap.Blocks.Length, dyMap.Blocks.Length);
                }
        }