简体   繁体   English

如何为C#wpf应用程序自定义Windows 8.1相机应用程序

[英]how to Customize windows 8.1 camera app for C# wpf application

I am creating WPF application, for my webcam section am using built-in metro camera app. 我正在创建WPF应用程序,对于我的网络摄像头部分,我正在使用内置的Metro Camera应用程序。 Since this application is an Desktop application, i just want to use Metro Camera app for the sake of capturing Image and editing. 由于此应用程序是桌面应用程序,因此我只想使用Metro Camera应用程序来捕获图像并进行编辑。 After capturing the images its getting saved in This PC-->Pictures folder, but i want to save the images in some other folder and also i want to give a name for the images manually. 捕获图像后,将其保存在“本机”->“图片”文件夹中,但是我想将图像保存在其他文件夹中,并且我也想手动为图像命名。 Is there any way to do this? 有什么办法吗?

Here is the code for saving images : 这是保存图像的代码:

    void SaveToBmp(FrameworkElement visual, string fileName)
{
    var encoder = new BmpBitmapEncoder();
    SaveUsingEncoder(visual, fileName, encoder);
}

void SaveToPng(FrameworkElement visual, string fileName)
{
    var encoder = new PngBitmapEncoder();
    SaveUsingEncoder(visual, fileName, encoder);
}

// and so on for other encoders (if you want)


void SaveUsingEncoder(FrameworkElement visual, string fileName, BitmapEncoder encoder)
{
    RenderTargetBitmap bitmap = new RenderTargetBitmap((int)visual.ActualWidth, (int)visual.ActualHeight, 96, 96, PixelFormats.Pbgra32);
    bitmap.Render(visual);
    BitmapFrame frame = BitmapFrame.Create(bitmap);
    encoder.Frames.Add(frame);

    using (var stream = File.Create(fileName))
    {
        encoder.Save(stream);
    }
}

Here is the source for that. 是它的来源。

Update : 更新:

If you want to save images in metro app you can use Pictures Library for that. 如果要将图像保存在metro app ,则可以使用Pictures Library

Read these following questions for that : 为此,请阅读以下问题:

Download and Save image in Pictures Library through Windows 8 Metro XAML App 通过Windows 8 Metro XAML App将图片下载并保存到图片库中

How save photo capture windows 8 c# metro app? 如何保存照片捕获Windows 8 C#Metro应用程序?

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Windows Phone 8.1在C#WPF应用程序中播放声音效果 - Windows Phone 8.1 play a sound effect in C# WPF application 如何在c#windows phone 8.1应用程序中写入excel文件? - how to write into the excel file in c# windows phone 8.1 application? 从现有的相机应用程序Windows Phone 8.1运行时C中获取图片 - get Picture from exising camera app Windows Phone 8.1 runtime c# 在Windows 8.1中从我的应用程序打开相机应用程序 - Open Camera Application From My App in Windows 8.1 通过解码“* .itemdata-ms”二进制数据文件(Windows 8.1,StartScreen,C#)自定义Windows 8.1 StartScreen - Customize Windows 8.1 StartScreen by decoding “*.itemdata-ms” binary data file (Windows 8.1, StartScreen, C#) 定制 gridview c# windows 应用 - Customize gridview c# windows application 从C#WPF更改Windows 8.1桌面的方向 - Change orientation of Windows 8.1 Desktop from C# wpf 在Windows Phone 8.1运行时上调用外部应用程序(非Silverlight)XAML C#应用程序 - Call an external app on windows phone 8.1 runtime(not silverlight) xaml c# application 如何在WPF C#中自定义这样的ListView? - How to customize a ListView like this in wpf c#? 如何在Visual Studio中使用C#代码从Windows 8.1商店应用程序重新启动Windows设备? - How to restart a windows device from my windows 8.1 store app using c# code in visual studios?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM