1

這是我迄今爲止嘗試的方向,我面臨的問題potraitdown它顯示圖像在兩個招,我想要做的是首先默認攝像頭的方向和第二放大和捕捉圖像使用canavas我可以放大和縮小相機,我也有方向錯誤的Windows Phone應用程序

之前縮小我在XAML

<Canvas x:Name="viewfinderCanvas" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,10"> 
     <Canvas.Background> 
      <VideoBrush x:Name="viewfinderBrush"> 
       <VideoBrush.RelativeTransform> 

       <CompositeTransform 
        x:Name="viewfinderTransform" 
        CenterX="0.5" 
        CenterY="0.5" 
        Rotation="-90" /> 

       </VideoBrush.RelativeTransform> 
      </VideoBrush> 
     </Canvas.Background> 
    </Canvas> 

寫了這個代碼這是用於定向C#

protected override void OnOrientationChanged(OrientationChangedEventArgs e) 
    { 

     if (cam != null) 
     { 

      if (e.Orientation == PageOrientation.LandscapeRight) 
      { 
       landscapeRightRotation = 180; 
       // Rotate for LandscapeRight orientation. 
       viewfinderBrush.RelativeTransform = 
        new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = landscapeRightRotation }; 
      } 
      else if (e.Orientation == PageOrientation.PortraitUp) 
      { 
       landscapeRightRotation = -90; 
       viewfinderBrush.RelativeTransform = 
        new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = landscapeRightRotation }; 
      } 

      else if (e.Orientation == PageOrientation.PortraitDown) 
      { 
       landscapeRightRotation = 0; 
       // Rotate for LandscapeRight orientation. 
       viewfinderBrush.RelativeTransform = 
        new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = landscapeRightRotation }; 
      } 
      else 
      { 

       viewfinderBrush.RelativeTransform = 
        new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = 0 }; 
      } 
     } 

     viewfinderTransform.ScaleY = 0; 
     base.OnOrientationChanged(e); 
    } 

回答

0

我是能夠解決的放大和縮小,加入兩件事情RenderTransformSlider,但仍面臨着更新的方向 XAML中的問題

 <Canvas x:Name="viewfinderCanvas" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,10"> 
     <Canvas.RenderTransform> 
      <ScaleTransform x:Name="zoom"/> 
      <!--<CompositeTransform scalex="-1"/>--> 
     </Canvas.RenderTransform> 
     <Canvas.Background> 

      <VideoBrush x:Name="viewfinderBrush"> 
       <VideoBrush.RelativeTransform> 

        <CompositeTransform 
        x:Name="viewfinderTransform" 
        CenterX="0.5" 
        CenterY="0.5" 
        Rotation="-90" /> 

       </VideoBrush.RelativeTransform> 
      </VideoBrush> 
     </Canvas.Background> 
    </Canvas> 
    <Slider Foreground="White" Value="1" Opacity=".3" Background="White" Visibility="Visible" Name="zoomSlider" ValueChanged="zoomSlider_ValueChanged_1" Margin="0,570,0,10" /> 

和C#for zoomSlider_ValueChanged_1

private void zoomSlider_ValueChanged_1(object sender, RoutedPropertyChangedEventArgs<double> e) 
    { 
     try 
     { 
      zoom.ScaleX = zoomSlider.Value; 
      zoom.ScaleY = zoomSlider.Value; 
      zoom.CenterX = 10; 
      zoom.CenterY = 5; 
     } 
     catch (Exception) 
     { 
     } 
    } 
+0

需要幫助以獲取默認方向或角度,因爲內置攝像頭具有 –

相關問題