Пример #1
0
        public void ReadSwfHeaderTest()
        {
            var mem    = new MemoryStream();
            var writer = new SwfStreamWriter(mem);
            var rect   = new SwfRect {
                XMin = 0x004,
                XMax = 0x48f,
                YMin = 0x008,
                YMax = 0x0ee
            };

            writer.WriteRect(ref rect);
            writer.WriteFixedPoint8(23.75);
            writer.WriteUInt16(20);
            mem.Seek(0, SeekOrigin.Begin);

            var reader = new SwfStreamReader(mem);
            var hdr    = reader.ReadSwfHeader();

            Assert.AreEqual(rect, hdr.FrameSize);
            Assert.AreEqual(23.75, hdr.FrameRate);
            Assert.AreEqual(20, hdr.FrameCount);

            Assert.AreEqual(mem.Length, mem.Position, "Should reach end of the stream");
        }
Пример #2
0
        public void WriteRectTest()
        {
            var rect = new SwfRect {
                XMin = 0,
                XMax = 11000,
                YMin = 0,
                YMax = 8000
            };
            var mem    = new MemoryStream();
            var writer = new SwfStreamWriter(mem);

            writer.WriteRect(ref rect);
            Assert.AreEqual(new byte[] { 0x78, 0x00, 0x05, 0x5f, 0x00, 0x00, 0x0f, 0xa0, 0x00 }, mem.ToArray());
        }
Пример #3
0
 public void WriteRectMustbeByteAlignedTest()
 {
     var rect = new SwfRect {
         XMin = 0,
         XMax = 11000,
         YMin = 0,
         YMax = 8000
     };
     var mem = new MemoryStream();
     var writer = new SwfStreamWriter(mem);
     writer.WriteRect(ref rect);
     writer.WriteUnsignedBits(0xb3, 8);
     Assert.AreEqual(new byte[] { 0x78, 0x00, 0x05, 0x5f, 0x00, 0x00, 0x0f, 0xa0, 0x00, 0xb3 }, mem.ToArray());
 }
Пример #4
0
        public void WriteRectTest2()
        {
            var rect = new SwfRect {
                XMin = 0x004,
                XMax = 0x48f,
                YMin = 0x008,
                YMax = 0x0ee
            };
            var mem    = new MemoryStream();
            var writer = new SwfStreamWriter(mem);

            writer.WriteRect(ref rect);
            writer.FlushBits();
            CheckBits(mem, "01100", "0000.00000100", "0100.10001111", "0000.00001000", "0000.11101110");
            mem.Seek(0, SeekOrigin.Begin);
        }
Пример #5
0
        public void ReadSwfHeaderTest()
        {
            var mem = new MemoryStream();
            var writer = new SwfStreamWriter(mem);
            var rect = new SwfRect {
                XMin = 0x004,
                XMax = 0x48f,
                YMin = 0x008,
                YMax = 0x0ee
            };
            writer.WriteRect(ref rect);
            writer.WriteFixedPoint8(23.75);
            writer.WriteUInt16(20);
            mem.Seek(0, SeekOrigin.Begin);

            var reader = new SwfStreamReader(mem);
            var hdr = reader.ReadSwfHeader();
            Assert.AreEqual(rect, hdr.FrameSize);
            Assert.AreEqual(23.75, hdr.FrameRate);
            Assert.AreEqual(20, hdr.FrameCount);

            Assert.AreEqual(mem.Length, mem.Position, "Should reach end of the stream");
        }
Пример #6
0
 public void WriteRectTest2()
 {
     var rect = new SwfRect {
         XMin = 0x004,
         XMax = 0x48f,
         YMin = 0x008,
         YMax = 0x0ee
     };
     var mem = new MemoryStream();
     var writer = new SwfStreamWriter(mem);
     writer.WriteRect(ref rect);
     writer.FlushBits();
     CheckBits(mem, "01100", "0000.00000100", "0100.10001111", "0000.00001000", "0000.11101110");
     mem.Seek(0, SeekOrigin.Begin);
 }