我想制作一个可以拍摄照片的应用程序,我可以将其保存到文件或显示到屏幕,但找不到从哪里开始。
I would recommend creating ac# Universal Windows App if you are targeting phone or desktop.
To take a picture you can use LowLagPhotoCapture to get a 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;
}
To see how to use (Save/Display/Edit) a SoftwareBitmap see the Imaging How-To
For more Windows camera documentation see GitHub Samples or MediaCapture How-To
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.