videobrushの向きを電話機の向きに合わせようとしていますが、この解決策を実装する際に問題があります。私のxamlページはPortraitOrLandscapeに設定されています。電話機の向きにかかわらず、ビデオカメラを右にしたいと思います。 onOrentationChangedイベントにif文姿勢変更を追加する前に、次のような状況ではvideobrushの向きが電話の向きと一致しない
電話を発生している:風景が残され、Videobrushを:アップ右側
電話:ポートレート、Videobrushは、回転-90時計回り
電話:風景右、Videobrushは、-180時計回り
XAML
<Rectangle x:Name="videoRectangle" Margin="0,0,0,0">
<Rectangle.Fill>
<VideoBrush x:Name="viewfinderBrush" AlignmentX="Left" AlignmentY="Top" Stretch="UniformToFill">
<VideoBrush.RelativeTransform>
<CompositeTransform x:Name="viewfinderTransform"
CenterX="0.5" CenterY="0.5"/>
</VideoBrush.RelativeTransform>
</VideoBrush>
</Rectangle.Fill>
</Rectangle>
XAML.CS回転しました
protected override void OnOrientationChanged(OrientationChangedEventArgs e)
{
base.OnOrientationChanged(e);
if (e.Orientation == PageOrientation.LandscapeLeft)
{ //do nothing
//The videobrush orientation is currently right side up
}
if (e.Orientation == PageOrientation.Portrait)
{
//the videobrush is currently rotated 90 degrees counter clockwise
this.viewfinderTransform.Rotation = this.camera.Orientation + 90.0;
}
if (e.Orientation == PageOrientation.LandscapeRight)
{
//the videobrush is currently rotated 180 degrees counter clockwise
this.viewfinderTransform.Rotation = this.camera.Orientation + 180;
}
}
ifステートメントを追加した後、videobrushの向きがさらに狂ってしまいます。私は間違って何をしていますか?私は単に、電話機の向きに関係なく、ビデオカメラを正しい向きにしたいと思っています。
あなたが表示しているもの以外に何かが起こっています。 XAML(コードビハインドなし)は、エミュレータと携帯電話で期待どおりに動作します。でも、私はなぜあなたが 'Rectangle'をペイントするために' VisualBrush'を使うのか、 'UniformToFill'オブジェクトを中心とする変換を提供するのかは分かりません。 –
this.viewfinderTransform.Rotation = this.camera.Orientation; これはうまくいきませんか? – TutuGeorge
@Ritch私は、ビデオカメラを使ってオブジェクト(矩形)をペイントすることに関して私が見つけたいくつかのMSDNソースを参照しています。私の場合、UniformToFillは、携帯電話を縦と横の間で回転させるときに幅と高さに差がないようにするために最も効果的です(ビデオビデオ画像が伸び縮みしていることに気付きました)。UniformToFillは、装置の回転。 – Matthew