C# 将文本添加到来自摄影机捕获的图像中
我正在尝试创建一个metro应用程序,它将从平板电脑摄像头捕获图像。 然而,在拍摄时,我想在图像上覆盖一个日期戳C# 将文本添加到来自摄影机捕获的图像中,c#,windows-store-apps,windows-8.1,C#,Windows Store Apps,Windows 8.1,我正在尝试创建一个metro应用程序,它将从平板电脑摄像头捕获图像。 然而,在拍摄时,我想在图像上覆盖一个日期戳 /// <summary> /// This is the click handler for the 'CaptureButton' button. /// </summary> /// <param name="sender"></param> /// <param name="e">&l
/// <summary>
/// This is the click handler for the 'CaptureButton' button.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private async void CapturePhoto_Click(object sender, RoutedEventArgs e)
{
try
{
rootPage.NotifyUser("", NotifyType.StatusMessage);
// Using Windows.Media.Capture.CameraCaptureUI API to capture a photo
CameraCaptureUI dialog = new CameraCaptureUI();
Size aspectRatio = new Size(16, 9);
dialog.PhotoSettings.CroppedAspectRatio = aspectRatio;
StorageFile file = await dialog.CaptureFileAsync(CameraCaptureUIMode.Photo);
if (file != null)
{
BitmapImage bitmapImage = new BitmapImage();
using (IRandomAccessStream fileStream = await file.OpenAsync(FileAccessMode.Read))
{
bitmapImage.SetSource(fileStream);
}
// add code for text overlay here
CapturedPhoto.Source = bitmapImage;
ResetButton.Visibility = Visibility.Visible;
// Store the file path in Application Data
appSettings[photoKey] = file.Path;
}
else
{
rootPage.NotifyUser("No photo captured.", NotifyType.StatusMessage);
}
}
catch (Exception ex)
{
rootPage.NotifyUser(ex.Message, NotifyType.ErrorMessage);
}
}
然而,似乎这个系统。绘图已经不存在了。我还可以使用什么在捕获的图像上覆盖文本?Windows.UI.Xaml没有直接光栅图形api。您可以从WriteableBitmap或BitmapDecoder获取原始像素,但并没有高级方法在方框中绘制它们 有几个选项可以在图像上绘制文本:
Graphics g = Graphics.FromImage