none
[UWP][C++/CX] code contribution for CameraCaptureUI class RRS feed

  • General discussion

  • Hi,

    here https://msdn.microsoft.com/library/windows/apps/br241030 ,

    there is a C# example about how to use the builtin dialog to take a photo (search // Using Windows.Media.Capture.CameraCaptureUI API to capture a photo ).

    Here is one for C++/Cx :

        CameraCaptureUI^ cameraCaptureUI = ref new CameraCaptureUI();
        cameraCaptureUI->PhotoSettings->Format = CameraCaptureUIPhotoFormat::Png;
        cameraCaptureUI->PhotoSettings->CroppedSizeInPixels = Size(100, 100);
    
        create_task(cameraCaptureUI->CaptureFileAsync(CameraCaptureUIMode::Photo)).then([this](StorageFile^ photo)
        {
            if (photo != nullptr) {
                auto toto = photo->Path;
                auto uri = ref new Windows::Foundation::Uri(toto);
                auto bitmapImage = ref new Windows::UI::Xaml::Media::Imaging::BitmapImage();
                bitmapImage->UriSource = uri;
                Image^ img= ref new Image();
                img->Source = bitmapImage;
                //...
            }
        });

    I won't claim that is perfect, but it's still an example who works.

    Thursday, August 11, 2016 12:20 PM