积极答复者
win8.1平板在使用CapturePhotoToStreamAsync()方法时闪退!

问题
-
private async void timerHandler(ThreadPoolTimer t) { try { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () => { IRandomAccessStream stream = new InMemoryRandomAccessStream(); await myCapture.CapturePhotoToStreamAsync(ImageEncodingProperties.CreatePng(), stream); // 在向流写入数据时,已经把指针移到结尾处 // 初始化图像是要先把指针移回开始位置 stream.Seek(0); var wrb = new WriteableBitmap(640, 480); wrb.SetSource(stream); Decode(wrb); }); } catch { } }
上面代码是将摄像头预览转为流数据的,运行在我的笔记本电脑中没有任何问题,但是运行在win8.1 10寸平板上就闪退,我不知道什么原因,也没法调试,我尝试注释这个方法内其他语句发现是这句代码引起的闪退await myCapture.CapturePhotoToStreamAsync(ImageEncodingProperties.CreatePng(), stream);
请问,这是什么原因造成的?
答案
-
你好
为什么没法调试,你可以尝试VS里面的一个RemoteDebug的功能。
不过既然笔记本上没问题,说明代码本身也没有问题,可能是平板上硬件的问题。你能告诉我这个问题是仅仅一个平板上出现的问题,还是多个平板上都有类似问题吗?
--James
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.- 已标记为答案 Aran.Wang 2014年6月9日 9:13
全部回复
-
你好
为什么没法调试,你可以尝试VS里面的一个RemoteDebug的功能。
不过既然笔记本上没问题,说明代码本身也没有问题,可能是平板上硬件的问题。你能告诉我这个问题是仅仅一个平板上出现的问题,还是多个平板上都有类似问题吗?
--James
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.- 已标记为答案 Aran.Wang 2014年6月9日 9:13
-
-
找到问题所在挺好的,本来我想上报上去让经验丰富的同事来看看,我这里也没有设备可以测试。
看了你的解决方案,似乎是因为平板的硬件资源的问题,属于一个performance的问题,Win8开发的核心还是以在保证运行效果的同时省电节约资源为主吧。
不过既然解决了不错,多谢对论坛的支持 :)
--James
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.- 已编辑 Jamles HezModerator 2014年6月10日 1:52