Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to set the zooming slider in windows 8.1 phone app

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 325
    Comment on it

    In this blog we illustrate how to set the zoom-in and zoom-out the focus of camera in windows 8.1 phone app.
    Foe zooming a camera we use a buit-in ZoomControl class inside the MediaCapture which controls the zooming of the camera.

     

    For the zooming the camera use the below code:


    Code for .Xaml file:

    <CaptureElement x:Name="capturePreview" Stretch="UniformToFill" />
    <Slider x:Name="FocusValueSlider" Margin="12,0,15,0" Header="Adjust focus:" ValueChanged="FocusValueSlider_ValueChanged" Width="300" FlowDirection="LeftToRight" VerticalAlignment="Bottom" HorizontalAlignment="Center" Slider>
    

     

    Code for .Xaml.cs file:

    MediaCapture _mediaCapture;
    
    // Initialization of the MediaCapture ...
    
    if(this._mediaCapture.VideoDeviceController.ZoomControl.Supported) //Check whether the using device supports a zooming control or not.
    {
        FocusValueSlider.Minimum = this.captureManager.VideoDeviceController.ZoomControl.Min;                    //Get the minimum zoom value supported by the capture device.
                        FocusValueSlider.Maximum = this.captureManager.VideoDeviceController.ZoomControl.Max;                    //Get the maximum zoom value supported by the capture device.
                        FocusValueSlider.StepFrequency = this.captureManager.VideoDeviceController.ZoomControl.Step;             //Get the smallest zoom value increment supported by the capture device.
                        FocusValueSlider.Value = ((FocusValueSlider.Minimum + FocusValueSlider.Maximum) / 2) / 2;
    }
    

     

    Code for slider when the its value is changes:

    private async void FocusValueSlider_ValueChanged(object sender, Windows.UI.Xaml.Controls.Primitives.RangeBaseValueChangedEventArgs e)
      {
    if (this.captureManager.VideoDeviceController.ZoomControl.Supported)           //Check whether zoom control is supported by the capture device.
                {
                        this.captureManager.VideoDeviceController.ZoomControl.Value = (float)e.NewValue;           //sets the zoom value to be used by the capture device.
                    }
                    else
                    {
                        msgDialog = new MessageDialog("This device does not support zoom in/out feature", "Info");
                        msgDialog.Commands.Add(new UICommand("OK"));
                        await msgDialog.ShowAsync();
                        FocusValueSlider.Value = 0;
              }
         }
      

     

     

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: