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))); }
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); }
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"); }
/// <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); }
/// <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); }
public static void ReadRGB(this ISwfStreamReader reader, out SwfRGB color) { color.Red = reader.ReadByte(); color.Green = reader.ReadByte(); color.Blue = reader.ReadByte(); }
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"); }