コード例 #1
0
        internal async void addEffectToImageStream()
        {
            if ((m_mediaCaptureMgr.MediaCaptureSettings.VideoDeviceCharacteristic != Windows.Media.Capture.VideoDeviceCharacteristic.AllStreamsIdentical) &&
                (m_mediaCaptureMgr.MediaCaptureSettings.VideoDeviceCharacteristic != Windows.Media.Capture.VideoDeviceCharacteristic.PreviewPhotoStreamsIdentical) &&
                (m_mediaCaptureMgr.MediaCaptureSettings.VideoDeviceCharacteristic != Windows.Media.Capture.VideoDeviceCharacteristic.RecordPhotoStreamsIdentical))
            {
                IMediaEncodingProperties props2 = m_mediaCaptureMgr.VideoDeviceController.GetMediaStreamProperties(Windows.Media.Capture.MediaStreamType.Photo);
                if (props2.GetType().Equals("Image")) //Cant add an effect to an image type
                {
                    //Change the media type on the stream
                    System.Collections.Generic.IReadOnlyList <IMediaEncodingProperties> supportedPropsList = m_mediaCaptureMgr.VideoDeviceController.GetAvailableMediaStreamProperties(Windows.Media.Capture.MediaStreamType.Photo);
                    int i = 0;
                    while (i++ < supportedPropsList.Count)
                    {
                        if (supportedPropsList[i].Type.Equals("Video"))
                        {
                            await m_mediaCaptureMgr.VideoDeviceController.SetMediaStreamPropertiesAsync(Windows.Media.Capture.MediaStreamType.Photo, supportedPropsList[i]);

                            ShowStatusMessage("Change type on image pin successful");
                            await m_mediaCaptureMgr.AddEffectAsync(Windows.Media.Capture.MediaStreamType.Photo, "GrayscaleTransform.GrayscaleEffect", null);

                            ShowStatusMessage("Add effect to photo successful");
                            m_bEffectAddedToPhoto        = true;
                            chkAddRemoveEffect.IsEnabled = true;
                            break;
                        }
                    }
                    chkAddRemoveEffect.IsEnabled = true;
                }
                else
                {
                    await m_mediaCaptureMgr.AddEffectAsync(Windows.Media.Capture.MediaStreamType.Photo, "GrayscaleTransform.GrayscaleEffect", null);

                    ShowStatusMessage("Add effect to photo successful");
                    chkAddRemoveEffect.IsEnabled = true;
                    m_bEffectAddedToPhoto        = true;
                }
            }
            else
            {
                chkAddRemoveEffect.IsEnabled = true;
            }
        }
コード例 #2
0
        internal async void chkAddRemoveEffect_Checked(Object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            try
            {
                chkAddRemoveEffect.IsEnabled = false;
                await m_mediaCaptureMgr.AddEffectAsync(Windows.Media.Capture.MediaStreamType.VideoPreview, "GrayscaleTransform.GrayscaleEffect", null);

                ShowStatusMessage("Add effect to video preview successful");
                if ((m_mediaCaptureMgr.MediaCaptureSettings.VideoDeviceCharacteristic != Windows.Media.Capture.VideoDeviceCharacteristic.AllStreamsIdentical) &&
                    (m_mediaCaptureMgr.MediaCaptureSettings.VideoDeviceCharacteristic != Windows.Media.Capture.VideoDeviceCharacteristic.PreviewRecordStreamsIdentical))
                {
                    IMediaEncodingProperties props = m_mediaCaptureMgr.VideoDeviceController.GetMediaStreamProperties(Windows.Media.Capture.MediaStreamType.VideoRecord);
                    if (!props.GetType().Equals("H264")) //Cant add an effect to an H264 stream
                    {
                        await m_mediaCaptureMgr.AddEffectAsync(Windows.Media.Capture.MediaStreamType.VideoRecord, "GrayscaleTransform.GrayscaleEffect", null);

                        ShowStatusMessage("Add effect to video record successful");
                        m_bEffectAddedToRecord = true;
                        addEffectToImageStream();
                    }
                    else
                    {
                        addEffectToImageStream();
                        chkAddRemoveEffect.IsEnabled = true;
                    }
                }
                else
                {
                    addEffectToImageStream();
                    chkAddRemoveEffect.IsEnabled = true;
                }
            }
            catch (Exception exception)
            {
                ShowExceptionMessage(exception);
            }
        }