private void _flightController_CameraFrameReceived(object sender, FlightCameraVideoFrameReceivedArgs e) { if (e.data != null) { BitmapImage img = new BitmapImage(); using (var ms = new MemoryStream(e.data)) { ms.Position = 0; img.BeginInit(); img.CreateOptions = BitmapCreateOptions.PreservePixelFormat; img.CacheOption = BitmapCacheOption.OnLoad; img.UriSource = null; img.StreamSource = ms; img.EndInit(); } camera.Source = img; } else { Dispatcher.Invoke(() => { log("image is null"); }); } }
private void _subscriber2_MessageReceived(object sender, MessageReceivedEventArgs e) { _mw.log(String.Format("[Message From Flight2] image:{0} x {1}", e.Message["width"].ToString(), e.Message["height"].ToString())); FlightCameraVideoFrameReceivedArgs args = new FlightCameraVideoFrameReceivedArgs(); args.data = e.Message["data"] != null ? e.Message["data"].ToObject <byte[]>() : null; Camera2FrameReceived.Invoke(this, args); }
private void _subscriber_MessageReceived(object sender, MessageReceivedEventArgs e) { //_mw.log(String.Format("[Message From Flight] {0}", e.Message.ToString())); FlightCameraVideoFrameReceivedArgs args = new FlightCameraVideoFrameReceivedArgs(); args.dataStr = e.Message["data"].ToString(); args.data = Convert.FromBase64String(e.Message["data"].ToString());//e.Message["data"] != null ? StringToByte(e.Message["data"].to) : null; CameraFrameReceived.Invoke(this, args); }