Beispiel #1
0
        public void ReadFixedPoint16FromBitsTest()
        {
            var          mem      = new MemoryStream();
            var          writer   = new SwfStreamWriter(mem);
            const int    val      = 0x03aa4523;
            const ushort hi       = val >> 16;
            const ushort low      = val & 0xffff;
            const double expected = hi + low / 65536.0;
            var          bits     = new SignedBitsCount(hi).GetBits();

            writer.WriteUnsignedBits(hi, bits);
            writer.WriteUnsignedBits(low, 16);
            writer.FlushBits();
            mem.Seek(0, SeekOrigin.Begin);
            var    reader = new SwfStreamReader(mem);
            double actual = reader.ReadFixedPoint16(bits + 16);

            Assert.AreEqual(expected, actual);
        }
Beispiel #2
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());
 }
Beispiel #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());
        }
Beispiel #4
0
        public void WriteUnsignedBitsTest()
        {
            var mem    = new MemoryStream();
            var writer = new SwfStreamWriter(mem);

            writer.WriteUnsignedBits(0x2ab, 10);
            writer.WriteBit(false);
            writer.WriteBit(false);
            writer.WriteBit(false);
            writer.WriteBit(false);
            writer.WriteBit(true);
            writer.WriteBit(true);

            mem.Seek(0, SeekOrigin.Begin);
            Assert.AreEqual(0xaa, mem.ReadByte());
            Assert.AreEqual(0xc3, mem.ReadByte());

            Assert.AreEqual(mem.Length, mem.Position, "Should reach end of the stream");
        }
Beispiel #5
0
        public void WriteUnsignedBitsTest()
        {
            var mem = new MemoryStream();
            var writer = new SwfStreamWriter(mem);
            writer.WriteUnsignedBits(0x2ab, 10);
            writer.WriteBit(false);
            writer.WriteBit(false);
            writer.WriteBit(false);
            writer.WriteBit(false);
            writer.WriteBit(true);
            writer.WriteBit(true);

            mem.Seek(0, SeekOrigin.Begin);
            Assert.AreEqual(0xaa, mem.ReadByte());
            Assert.AreEqual(0xc3, mem.ReadByte());

            Assert.AreEqual(mem.Length, mem.Position, "Should reach end of the stream");
        }
Beispiel #6
0
 public void ReadFixedPoint16FromBitsTest()
 {
     var mem = new MemoryStream();
     var writer = new SwfStreamWriter(mem);
     const int val = 0x03aa4523;
     const ushort hi = val >> 16;
     const ushort low = val & 0xffff;
     const double expected = hi + low / 65536.0;
     var bits = new SignedBitsCount(hi).GetBits();
     writer.WriteUnsignedBits(hi, bits);
     writer.WriteUnsignedBits(low, 16);
     writer.FlushBits();
     mem.Seek(0, SeekOrigin.Begin);
     var reader = new SwfStreamReader(mem);
     double actual = reader.ReadFixedPoint16(bits + 16);
     Assert.AreEqual(expected, actual);
 }