使用 Win RT 从相机捕获快照
我正在编写从相机捕获图像的代码。下面是我编写的代码。 这里方法 CapturePhotoToStorageFileAsync 不返回。
auto MediaCap = ref new Windows::Media::Capture::MediaCapture();
auto ImageProp = ref new Windows::Media::Capture::ImageEncodingProperties ();
ImageProp->Height = 240;
ImageProp->Width = 320;
ImageProp->Subtype = "JPEG";
Windows::Storage::StorageFile^ strFile;
auto res = MediaCap->CapturePhotoToStorageFileAsync(ImageProp,strFile);
res->Completed = ref new AsyncActionCompletedHandler([](IAsyncAction ^action)
{
//action->GetResults();
//action->Start();
///action->Close();
});
res->Start();
我在这里错过了什么吗?
I am Wrting code to capture image from camera.Below is the code I have written.
Here method CapturePhotoToStorageFileAsync doesnot return.
auto MediaCap = ref new Windows::Media::Capture::MediaCapture();
auto ImageProp = ref new Windows::Media::Capture::ImageEncodingProperties ();
ImageProp->Height = 240;
ImageProp->Width = 320;
ImageProp->Subtype = "JPEG";
Windows::Storage::StorageFile^ strFile;
auto res = MediaCap->CapturePhotoToStorageFileAsync(ImageProp,strFile);
res->Completed = ref new AsyncActionCompletedHandler([](IAsyncAction ^action)
{
//action->GetResults();
//action->Start();
///action->Close();
});
res->Start();
Am I missing something here??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您想向用户展示 UI 还是只是默默地捕获?我发现的唯一 C++ 相机示例 使用 CameraCaptureUI和 CaptureFileAsync - 然后操作将获取 StorageFile^ 回来。
如果您有意使用 CapturePhotoToStorageFileAsync,请检查您的能力。
Did you want to show UI to the user or just silently capture? The only C++ camera sample I've found uses CameraCaptureUI and CaptureFileAsync - then the operation is getting a StorageFile^ back.
If you're deliberately using CapturePhotoToStorageFileAsync, check your capabiities.
问题已解决
的代码
使用
Windows::Storage::StorageFileRetrievalOperation^ CreateFileOp = Windows::Storage::KnownFolders::PicturesLibrary->CreateFileAsync("Test.jpg");
我找到了Java脚本文章并用C++实现。
http://code.msdn.microsoft.com/windowsdesktop/Media-Capture-Sample-adf87622/sourcecode?fileId=43837&pathId=1754477665
The Issue is resolved
I Added code for
using
Windows::Storage::StorageFileRetrievalOperation^ CreateFileOp = Windows::Storage::KnownFolders::PicturesLibrary->CreateFileAsync("Test.jpg");
I found Java script article and implemented in c++.
http://code.msdn.microsoft.com/windowsdesktop/Media-Capture-Sample-adf87622/sourcecode?fileId=43837&pathId=1754477665