Example #1
0
 public static void AreEqual(SwfRGBA expected, SwfRGBA actual, string message)
 {
     Assert.AreEqual(expected.Red, actual.Red, message + ": Red");
     Assert.AreEqual(expected.Green, actual.Green, message + ": Green");
     Assert.AreEqual(expected.Blue, actual.Blue, message + ": Blue");
     Assert.AreEqual(expected.Alpha, actual.Alpha, message + ": Alpha");
 }
Example #2
0
 public static XElement ToXml(SwfRGBA color)
 {
     return new XElement("Color",
         new XAttribute("red", color.Red),
         new XAttribute("green", color.Green),
         new XAttribute("blue", color.Blue),
         new XAttribute("alpha", color.Alpha));
 }
Example #3
0
 public static SwfRGBA FromXml(XElement xColor)
 {
     var color = new SwfRGBA();
     var xRed = xColor.Attribute("red");
     var xGreen = xColor.Attribute("green");
     var xBlue = xColor.Attribute("blue");
     var xAlpha = xColor.Attribute("alpha");
     color.Red = xRed != null ? byte.Parse(xRed.Value) : (byte)0;
     color.Green = xGreen != null ? byte.Parse(xGreen.Value) : (byte)0;
     color.Blue = xBlue != null ? byte.Parse(xBlue.Value) : (byte)0;
     color.Alpha = xAlpha != null ? byte.Parse(xAlpha.Value) : (byte)0;
     return color;
 }
Example #4
0
        public void WriteRGBATest()
        {
            var val = new SwfRGBA(0x0a, 0xff, 0x83, 0x12);
            var mem = new MemoryStream();
            var writer = new SwfStreamWriter(mem);
            writer.WriteRGBA(ref val);
            mem.Seek(0, SeekOrigin.Begin);

            Assert.AreEqual(0x0a, mem.ReadByte(), "Byte 0");
            Assert.AreEqual(0xff, mem.ReadByte(), "Byte 1");
            Assert.AreEqual(0x83, mem.ReadByte(), "Byte 2");
            Assert.AreEqual(0x12, mem.ReadByte(), "Byte 3");

            Assert.AreEqual(mem.Length, mem.Position, "Should reach end of the stream");
        }