标签:style blog http color os strong 数据 for
开始先展示下效果图:
-------------------------------下面记录步骤:------------------------------------------------------
1 //定义一个用于传到UI照片数据的属性 2 public byte[] CaptureData { get; set; } 3 4 /// <summary> 5 /// 点击“拍照” 6 /// </summary> 7 private void btnCapture_Click(object sender, RoutedEventArgs e) 8 { 9 RenderTargetBitmap bmp = new RenderTargetBitmap((int)captureElement.ActualWidth,(int)captureElement.ActualHeight, 10 96,96,PixelFormats.Default); 11 bmp.Render(captureElement); 12 BitmapEncoder encoder = new JpegBitmapEncoder(); 13 encoder.Frames.Add(BitmapFrame.Create(bmp)); 14 using (MemoryStream ms = new MemoryStream()) 15 { 16 encoder.Save(ms); 17 CaptureData = ms.ToArray(); //将形成的照片留传递给属性 18 } 19 captureElement.Pause(); 20 } 21 //点击确定 22 private void btnOK_Click(object sender, RoutedEventArgs e) 23 { 24 DialogResult = true; 25 }
WPF中实现拍照功能(利用“WPFMediaKit.dll”),布布扣,bubuko.com
WPF中实现拍照功能(利用“WPFMediaKit.dll”)
标签:style blog http color os strong 数据 for
原文地址:http://www.cnblogs.com/tianqy/p/3918246.html