2016-04-26 119 views

回答

0

如果您的目标是手机或桌面,我会建议您创建一个c#Universal Windows App

要拍摄,您可以使用LowLagPhotoCapture获得SoftwareBitmap

public async Task<SoftwareBitmap> takePhotoToSoftwareBitmap() 
    { 
     //initialize mediacapture with default camera 
     var mc = new MediaCapture(); 
     await mc.InitializeAsync(); 

     //create low lag capture and take photo 
     var lowLagCapture = await mc.PrepareLowLagPhotoCaptureAsync(ImageEncodingProperties.CreateUncompressed(MediaPixelFormat.Bgra8)); 
     var photo = await lowLagCapture.CaptureAsync(); 

     //convert to displayable format 
     SoftwareBitmap displayableImage; 
     using (var frame = photo.Frame) 
     { 
      displayableImage = SoftwareBitmap.Convert(photo.Frame.SoftwareBitmap, BitmapPixelFormat.Bgra8, BitmapAlphaMode.Premultiplied); 
     } 

     return displayableImage; 
    } 

要了解如何使用(保存/显示/编辑)一SoftwareBitmap看到Imaging How-To

欲了解更多Windows摄像头文档看到图片GitHub Samples