public static Byte[] CreateByteArray(params Object[] Args) { Byte[] Ret = new Byte[] { }; for (Int32 i = 0; i < Args.Length; i++) { Ret = Args[i].GetType() == typeof(Byte) ? Ret.Append(new Byte[] { (Byte)Args[i] }) // this is done like so because Args is Object and BitCovnerter doesnt support Objects : Ret.Append((Byte[])typeof(BitConverter).GetMethod("GetBytes", new Type[] { Args[i].GetType() }).Invoke(null, new Object[] { Args[i] })); } return(Ret); }
public void AnimateImages(IEnumerable <string> images, int delay = 0) { var result = new Byte[0]; var header = new Byte[] { 0xbf, 0x00, 0x49, 0x00, 0x0a, 0x0a, 0x04 }; int fi = 0; foreach (var file in images) { byte[] imageData = ConvertImage(file); byte[] payload = header .Append(new byte[] { (byte)fi, (byte)delay }) .Append(imageData); fi++; byte[] message = BuildMessage(payload); result = result.Append(message); } _client.GetStream().Write(result, 0, result.Length); }