Exemple #1
0
 public static XElement ToXml(SwfRGB color)
 {
     return(new XElement("Color",
                         new XAttribute("red", color.Red),
                         new XAttribute("green", color.Green),
                         new XAttribute("blue", color.Blue)));
 }
Exemple #2
0
        public static SwfRGB FromXml(XElement xColor)
        {
            var color  = new SwfRGB();
            var xRed   = xColor.Attribute("red");
            var xGreen = xColor.Attribute("green");
            var xBlue  = xColor.Attribute("blue");

            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;

            return(color);
        }
Exemple #3
0
        public void WriteRGBTest()
        {
            var val    = new SwfRGB(0x0a, 0xff, 0x83);
            var mem    = new MemoryStream();
            var writer = new SwfStreamWriter(mem);

            writer.WriteRGB(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(mem.Length, mem.Position, "Should reach end of the stream");
        }
Exemple #4
0
 /// <summary>
 /// Writes the RGB color to writer.
 /// </summary>
 /// <param name="writer">The writer to which to write color.</param>
 /// <param name="val">Color to be written.</param>
 public static void WriteRGB(this ISwfStreamWriter writer, ref SwfRGB val)
 {
     writer.WriteByte(val.Red);
     writer.WriteByte(val.Green);
     writer.WriteByte(val.Blue);
 }
Exemple #5
0
 /// <summary>
 /// Writes the RGB color to writer.
 /// </summary>
 /// <param name="writer">The writer to which to write color.</param>
 /// <param name="val">Color to be written.</param>
 public static void WriteRGB(this ISwfStreamWriter writer, SwfRGB val)
 {
     writer.WriteRGB(ref val);
 }
Exemple #6
0
 public static void ReadRGB(this ISwfStreamReader reader, out SwfRGB color)
 {
     color.Red = reader.ReadByte();
     color.Green = reader.ReadByte();
     color.Blue = reader.ReadByte();
 }
Exemple #7
0
 public static void AreEqual(SwfRGB expected, SwfRGB 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");
 }
Exemple #8
0
 /// <summary>
 /// Writes the RGB color to writer.
 /// </summary>
 /// <param name="writer">The writer to which to write color.</param>
 /// <param name="val">Color to be written.</param>
 public static void WriteRGB(this ISwfStreamWriter writer, ref SwfRGB val)
 {
     writer.WriteByte(val.Red);
     writer.WriteByte(val.Green);
     writer.WriteByte(val.Blue);
 }
Exemple #9
0
 /// <summary>
 /// Writes the RGB color to writer.
 /// </summary>
 /// <param name="writer">The writer to which to write color.</param>
 /// <param name="val">Color to be written.</param>
 public static void WriteRGB(this ISwfStreamWriter writer, SwfRGB val)
 {
     writer.WriteRGB(ref val);
 }
Exemple #10
0
 public static void ReadRGB(this ISwfStreamReader reader, out SwfRGB color)
 {
     color.Red   = reader.ReadByte();
     color.Green = reader.ReadByte();
     color.Blue  = reader.ReadByte();
 }