private void onShareTimerTickHandle(object sender, EventArgs e) { try { log.Info(string.Format("SetContentBuffer({0},{1},{2}) ", call.ContentImageFormat, call.ContentType, call.ContentHandle)); #region Image Bitmap image = null; var rect = new Rectangle(); if (null == call.ContentHandle) { return; } if (call.ContentType == ContentType.Monitor) { image = ImageHelper.CaptureScreen(call.ContentHandle, ref rect); } else { image = ImageHelper.CaptureApplication(call.ContentHandle, ref rect); } #endregion if (null != image) { log.Info(string.Format("SetContentBuffer({0},{1},{2})", call.ContentImageFormat, image.Width, image.Height)); this.Bounds = rect; #region Resolution Size size = new Size(); if (image.Width <= 320 && image.Height <= 240) { size = new Size(320, 240); } else if (image.Width <= 432 && image.Height <= 240) { size = new Size(432, 240); } else if (image.Width <= 640 && image.Height <= 480) { size = new Size(640, 480); } else if (image.Width <= 704 && image.Height <= 576) { size = new Size(704, 576); } else if (image.Width <= 800 && image.Height <= 600) { size = new Size(800, 600); } else if (image.Width <= 1024 && image.Height <= 576) { size = new Size(1024, 576); } else if (image.Width <= 1024 && image.Height <= 768) { size = new Size(1024, 768); } else { size = new Size(1280, 720); } #endregion var scaledImage = ImageHelper.ScaleImage(image, size); #region Bytes byte[] buffer = null; if (call.ContentImageFormat == ImageFormat.YV12) { buffer = ImageHelper.GetYUV(scaledImage); } else { buffer = ImageHelper.GetRGBA(scaledImage); } #endregion var errno = PlcmProxy.SetContentBuffer(call.ContentImageFormat, buffer, scaledImage.Width, scaledImage.Height); if (ErrorNumber.OK != errno) { log.Error("SetContentBuffer 失败, ex:" + errno); this.Hide(); } else { channel.LocalContentImage = scaledImage; this.Show(); } } else { throw new Exception("捕捉图像失败"); } } catch (Exception ex) { log.Error(ex.Message); } }