我正在创建WPF应用程序,因为我的摄像头部分正在使用内置的地铁相机应用程序。由于此应用程序是一个桌面应用程序,我只想使用Metro Camera应用程序来捕获图像和编辑。捕获图像后,它保存在This PC - > Pictures文件夹中,但我想将图像保存在其他文件夹中,同时我也想手动为图像命名。有没有办法做到这一点?如何为C#wpf应用程序定制windows 8.1相机应用程序
1
A
回答
1
这里是保存图像的代码:
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是针对源。
更新:
如果你想保存在metro app
图像,你可以使用Pictures Library
了点。
阅读这些以下问题:
Download and Save image in Pictures Library through Windows 8 Metro XAML App
How save photo capture windows 8 c# metro app?
希望它能帮助。
相关问题
- 1. 从Windows 8.1中的我的应用程序打开相机应用程序
- 2. System.Windows.Media在Windows手机应用程序8.1
- 3. C# - 为wpf应用程序定制安装程序
- 4. 如何为Windows Phone 8.1应用程序制作实时切片?
- 5. Windows 8 WPF应用程序
- 6. Windows Phone 8.1到通用应用程序
- 7. Windows 8.1通用应用程序文档
- 8. Windows 8.1通用应用程序参考
- 9. C#/ WPF应用程序实现应用程序CLI的简单IPC机制
- 10. Windows Phone 8.1应用程序 - 如何获取到我的手机?
- 11. 在Windows 8.1中开发Windows应用程序,如OneDrive应用程序
- 12. 开发WPF应用程序,如Windows 10设置应用程序
- 13. 开始应用商店 - 用于Windows Phone 8.1和Windows 8.1应用程序的通用应用程序
- 14. 从Windows窗体应用程序C控制台应用程序#
- 15. 如何隐藏Windows Phone 8.1(WinJS)应用程序中的应用程序栏?
- 16. 如何从Windows Phone 8.1中的其他应用程序启动应用程序
- 17. 如何与Windows 8.1应用程序一起发布UWP应用程序?
- 18. 通用应用程序中的Windows 8.1 WPF控件
- 19. 在Windows 8.1 Universal应用程序中使用WPF .NET API
- 20. Windows 8.1商店应用程序开发
- 21. Windows Phone应用程序8.1中的Epub
- 22. Windows Phone 8.1运行时应用程序
- 23. Windows 8.1中的UnmanagedType.CustomMarshaler应用程序
- 24. Windows 8.1应用程序中的态度
- 25. 事件在Windows 8.1应用程序
- 26. 暂停应用程序Windows Phone 8.1
- 27. 发布Windows Phone 8.1应用程序
- 28. PDF生成在Windows应用程序8.1
- 29. Windows phone 8.1 silverlight应用程序
- 30. Windows Phone 8.1照片应用程序
更新的答案是否适合您? – aliboy38 2015-03-02 13:13:22
[this](http://stackoverflow.com/questions/16858376/download-and-save-image-in-pictures-library-through-windows-8-metro-xaml-app)不工作... – Ranjith 2015-03-02 13:36:29
它应该工作。你可能在某处做错了什么。尝试再次查看并阅读其他链接。 – aliboy38 2015-03-02 16:22:51