public static void WriteColorTransformRGB(this ISwfStreamWriter writer, ref ColorTransformRGB tranform) { var bitsCounter = new SignedBitsCount(0); if (tranform.HasAddTerms) { bitsCounter.AddValue(tranform.RedAddTerm); bitsCounter.AddValue(tranform.GreenAddTerm); bitsCounter.AddValue(tranform.BlueAddTerm); } if (tranform.HasMultTerms) { bitsCounter.AddValue(tranform.RedMultTerm); bitsCounter.AddValue(tranform.GreenMultTerm); bitsCounter.AddValue(tranform.BlueMultTerm); } writer.WriteBit(tranform.HasAddTerms); writer.WriteBit(tranform.HasMultTerms); var bits = bitsCounter.GetBits(); writer.WriteUnsignedBits(bits, 4); if (tranform.HasMultTerms) { writer.WriteSignedBits(tranform.RedMultTerm, bits); writer.WriteSignedBits(tranform.GreenMultTerm, bits); writer.WriteSignedBits(tranform.BlueMultTerm, bits); } if (tranform.HasAddTerms) { writer.WriteSignedBits(tranform.RedAddTerm, bits); writer.WriteSignedBits(tranform.GreenAddTerm, bits); writer.WriteSignedBits(tranform.BlueAddTerm, bits); } writer.FlushBits(); }
public static void AreEqual(ColorTransformRGB expected, ColorTransformRGB actual, string message) { Assert.AreEqual(expected.HasAddTerms, actual.HasAddTerms, message + ".HasAddTerms"); Assert.AreEqual(expected.HasMultTerms, actual.HasMultTerms, message + ".HasMultTerms"); Assert.AreEqual(expected.RedAddTerm, actual.RedAddTerm, message + ".RedAddTerm"); Assert.AreEqual(expected.GreenAddTerm, actual.GreenAddTerm, message + ".GreenAddTerm"); Assert.AreEqual(expected.BlueAddTerm, actual.BlueAddTerm, message + ".BlueAddTerm"); Assert.AreEqual(expected.RedMultTerm, actual.RedMultTerm, message + ".RedMultTerm"); Assert.AreEqual(expected.GreenMultTerm, actual.GreenMultTerm, message + ".GreenMultTerm"); Assert.AreEqual(expected.BlueMultTerm, actual.BlueMultTerm, message + ".BlueMultTerm"); }
public static XElement ToXml(ColorTransformRGB transform) { var res = new XElement(TAG_NAME); if (transform.HasMultTerms) { res.Add(new XAttribute("factorRed", transform.RedMultTerm)); res.Add(new XAttribute("factorGreen", transform.GreenMultTerm)); res.Add(new XAttribute("factorBlue", transform.BlueMultTerm)); } if (transform.HasAddTerms) { res.Add(new XAttribute("redadd", transform.RedAddTerm)); res.Add(new XAttribute("greenadd", transform.GreenAddTerm)); res.Add(new XAttribute("blueadd", transform.BlueAddTerm)); } return res; }
public static void WriteColorTransformRGB(this ISwfStreamWriter writer, ColorTransformRGB tranform) { writer.WriteColorTransformRGB(ref tranform); }
public void WriteColorTransformRGBFromBitsAddTest() { var mem = new MemoryStream(); var writer = new SwfStreamWriter(mem); var tranform = new ColorTransformRGB { RedMultTerm = 0, GreenMultTerm = 0, BlueMultTerm = 0, HasMultTerms = false, RedAddTerm = 10, GreenAddTerm = -10, BlueAddTerm = 224, HasAddTerms = true }; writer.WriteColorTransformRGB(ref tranform); CheckBits(mem, "1", "0", "1001", "0.00001010", "1.11110110", "0.11100000"); }