<ScaleTransform>
不修改相机的变焦。它只是放大图像,因此您会看到相同的图像更加像素化。
相机的变焦是由ZoomControl
类控制的。它位于MediaCapture
课堂内。
示例:Slider
元素更改相机的缩放。
<CaptureElement x:Name="captureElement"
Stretch="UniformToFill" />
<Slider x:Name="sliderZoom"
Width="250"
ValueChanged="sliderZoom_ValueChanged"/>
的配置Slider
:
MediaCapture _mediaCapture;
// Initialization of the MediaCapture ...
if(this._mediaCapture.VideoDeviceController.ZoomControl.Supported)
{
sliderZoom.Minimum = this._mediaCapture.VideoDeviceController.ZoomControl.Min;
sliderZoom.Maximum = this._mediaCapture.VideoDeviceController.ZoomControl.Max;
sliderZoom.StepFrequency = this._mediaCapture.VideoDeviceController.ZoomControl.Step;
}
Slider
当改变其值时修改相机的缩放:
private void sliderZoom_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
{
if(this._mediaCapture.VideoDeviceController.ZoomControl.Supported)
{
this._mediaCapture.VideoDeviceController.ZoomControl.Value = (float)e.NewValue;
}
}
如果StepFrequency
不等于ZoomControl.Step
尝试修改缩放时将显示此错误:
An exception of type 'System.ArgumentException' occurred in ....exe but was not handled in user code
WinRT information: Zoom factor
Additional information: The parameter is incorrect.