Windows Phone 8.1 多媒体(1):相片
原文:Windows Phone 8.1 多媒体(1):相片
Windows Phone 8.1 多媒体(1):相片
(1)拍摄相片
1)CaptureElement
CaptureElement 是放在应用界面上预览拍照的控件:
<Grid>
<CaptureElement x:Name="capturePhotoElement"/>
</Grid> <Page.BottomAppBar>
<CommandBar>
<AppBarButton x:Name="btnCapturePhoto"
Icon="Camera" Label="Capture"
Click="btnCapturePhoto_Click"/>
</CommandBar>
</Page.BottomAppBar>
2)MediaCapture
MediaCapture 是控制拍摄的重要类。
首先初始化 MediaCapture,并将 CaptureElement 的 Source 设为 该 MediaCapture:
MediaCapture photoCapture;
ImageEncodingProperties imgEncodingProperties; protected override async void OnNavigatedTo(NavigationEventArgs e)
{
capturePhotoElement.Source = await Initialize(); await photoCapture.StartPreviewAsync();
} private async Task<MediaCapture> Initialize()
{
photoCapture = new MediaCapture();
await photoCapture.InitializeAsync(); photoCapture.VideoDeviceController.PrimaryUse = CaptureUse.Photo; imgEncodingProperties = ImageEncodingProperties.CreateJpeg();
imgEncodingProperties.Width = ;
imgEncodingProperties.Height = ; return photoCapture;
}
然后在按下某个按钮的时候完成拍摄:
private async void btnCapturePhoto_Click(object sender, RoutedEventArgs e)
{
var photo = await KnownFolders.PicturesLibrary.CreateFileAsync("photo.jpg", CreationCollisionOption.GenerateUniqueName); await photoCapture.CapturePhotoToStorageFileAsync(imgEncodingProperties, photo);
}
也可以添加手机实体按键的事件:
HardwareButtons.CameraHalfPressed += HardwareButtons_CameraHalfPressed; async void HardwareButtons_CameraHalfPressed(object sender, CameraEventArgs e)
{
await photoCapture.VideoDeviceController.FocusControl.FocusAsync();
}
最后记得在离开页面时释放 MediaCapture 资源:
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
if( photoCapture != null )
{
photoCapture.Dispose();
photoCapture = null;
}
}
(2)编辑相片
我在这里使用了 Nokia Imaging SDK 和 WritableBitmapEx 库,可在 Nuget 中搜索并安装。
注意要将配置管理器中的 CPU 改成 ARM,否则 Nokia Imaging SDK 将不可用。
使用方法非常简单,比如以下为一张图片添加滤镜:
WriteableBitmap originBitmap;
WriteableBitmap editedBitmap; private async void editButton_Click(object sender, RoutedEventArgs e)
{
var imageSource = new BitmapImageSource(originBitmap.AsBitmap()); using( var effect = new FilterEffect(imageSource) )
{
var filter = new AntiqueFilter(); effect.Filters = new[] { filter }; var renderer = new WriteableBitmapRenderer(effect, originBitmap);
editedBitmap = await renderer.RenderAsync(); editedBitmap.Invalidate();
} myImage.Source = editedBitmap;
}
更多的使用方法可到诺基亚帮助中心查看:链接
Windows Phone 8.1 多媒体(1):相片的更多相关文章
- Windows Phone 8.1 多媒体(3):音乐
原文:Windows Phone 8.1 多媒体(3):音乐 Windows Phone 8.1 多媒体(1):相片 Windows Phone 8.1 多媒体(2):视频 Windows Phone ...
- Windows Phone 8.1 多媒体(2):视频
原文:Windows Phone 8.1 多媒体(2):视频 Windows Phone 8.1 多媒体(1):相片 Windows Phone 8.1 多媒体(2):视频 Windows Phone ...
- C# Winform使用Windows Media Player播放多媒体整理
一.简单使用示例步骤 1.添加Windows Media Player 组件当前是系统的 Com组件 工具箱>右键“选择项”>选择Com组件 2.控件拖拽到桌面,使用 private vo ...
- windows live writer插件说明文档(附录网盘地址)
百度云地址:http://pan.baidu.com/s/1hqnjzjY 1.Screen Capture tool 用于直接在WLWriter中进行截图的一个插件,要配合SnagIt 这个软件使用 ...
- Windows 8.1 Preview的新功能和新API
http://msdn.microsoft.com/en-us/library/windows/apps/bg182410 App打包 新的App程序包将使App的提交更简单.资源包可以让你提供附加的 ...
- 通过使用 NTLite 工具实现精简Windows系统
NTLite 是一款专业于Windows平台的系统精简工具,NTLite主要面对系统封装人员使用,比如各大下载站及GHO镜像下载站,Windows系统二次精简封装打包使用,NTLite可以对系统进行极 ...
- Windows高速定时器,多媒体定时器winmm.dll库的使用
项目里面用到的这些看起来名字高大上的定时器测试下来也是非常不准.看了源码发现也是用System.Timers.Timer或者用的是Thread休眠的方式来实现的.100毫秒就不准了.直到一番搜索,发现 ...
- Windows 常用运行库下载 (DirectX、VC++、.Net Framework等)
经常听到有朋友抱怨他的电脑运行软件或者游戏时提示缺少什么 d3dx9_xx.dll 或 msvcp71.dll.msvcr71.dll又或者是 .Net Framework 初始化之类的错误而无法正常 ...
- 【Win 10 应用开发】在后台进行多媒体转码
前面,老周给大伙儿讲了如何运用 MediaTranscoder 类来完成多媒体.然而,你懂的,要是多媒体文件比较大,转码时间会更长,有可能用户不会一眭停在当前应用界面上,或许会切换到其他应用程序,甚至 ...
随机推荐
- Singleton模式(Singleton创建类型)c#简单的例子
单(Singleton创建模式)c#简单的例子 当需要生成一个实例,可单发模式 样品可以在短短的球员中产生,玩家和测试.单线程例子,如以下: namespace singletonpattern { ...
- Mongodb 之insert瞬时完成,测试数据---飞天博客
这几天看mongdb官方网站,然后将执行数据.突然,我发现,该数据确实很强大,在这里说话数据.我用普通的pc机,amd双核 2.7GHz,4G内存,当然,当系统不只是在测试作为数据库server的.同 ...
- JAVA中类以及成员变量和成员方法的修饰符的总结
一 类的修饰符 java中的文件结构由大到小为:一个工程,一个工程下可以有许多包,每个包中可以有许多类. 类的修饰符分为 访问权限修饰符 和 ...
- MySQL性能、监控与灾难恢复
原文:MySQL性能.监控与灾难恢复 监控方案: up.time http://www.uptimesoftware.com/ 收费 Cacti http:/ ...
- android中怎么把自己须要的app启动图标集中到一个弹出框中
先看效果图 这个是我们自己的apk点击之后的效果 下边是布局文件 activity_main.xml主布局文件 <LinearLayout xmlns:android="http:// ...
- 国内Android应用推广的六大主流方式
国内Android应用推广的六大主流方式 http://mobi.baike.com/article-19433.html 随着Android市场份额的飞速增长,越来越多的国内开发团队和公司開始投入A ...
- 模拟Vue之数据驱动3
一.前言 在"模拟Vue之数据驱动2"中,我们实现了个Observer构造函数,通过它可以达到监听已有数据data中的所有属性. 但,倘若我们想在某个对象中,新增某个属性呢? 如下 ...
- Qt Mac 在软件 icns图标制作
1.首先,下载一个电话Icon Composer软件 之前Xcode像这个东西,现在,我不知道有或无,迷茫,一世Xcode很少. Icon Composer是苹果出的. 下载地址: http://ww ...
- Codeforces 110B-Lucky String(技能)
B. Lucky String time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- dojo/dom源码
dojo/dom源码学习 dojo/dom模块作为一个基础模块,最常用的就是byId方法.除此之外还有isDescendant和setSelectable方法. dom.byId(myId)方法: ...