public static void Write(BinaryWriter writer, OscColor value) { uint intValue = unchecked ((uint)( ((byte)value.R << 24) | ((byte)value.G << 16) | ((byte)value.B << 8) | ((byte)value.A << 0))); Write(writer, intValue); }
public static OscColor ReadColor(System.IO.BinaryReader reader) { uint value = ReadUInt32(reader); byte a, r, g, b; r = (byte)((value & 0xFF000000) >> 24); g = (byte)((value & 0x00FF0000) >> 16); b = (byte)((value & 0x0000FF00) >> 8); a = (byte)(value & 0x000000FF); return(OscColor.FromArgb(a, r, g, b)); }
public static object ParseColor(string str, IFormatProvider provider) { string[] pieces = str.Split(','); if (pieces.Length == 4) { byte a, r, g, b; r = byte.Parse(pieces[0].Trim(), System.Globalization.NumberStyles.None, provider); g = byte.Parse(pieces[1].Trim(), System.Globalization.NumberStyles.None, provider); b = byte.Parse(pieces[2].Trim(), System.Globalization.NumberStyles.None, provider); a = byte.Parse(pieces[3].Trim(), System.Globalization.NumberStyles.None, provider); return(OscColor.FromArgb(a, r, g, b)); } else { throw new Exception($"Invalid color \'{str}\'"); } }
public static string ToStringColor(OscColor color) { return($"{color.R}, {color.G}, {color.B}, {color.A}"); }