I added camera to an my App which is all in Portrait mode so would like the to keep it this way.
Here is the relevant code snippets I use in my .XAML
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="480"
<Canvas x:Name="viewfinderCanvas" Width="480" Height="800" >
<!--Camera viewfinder -->
<Canvas.Background>
<VideoBrush x:Name="viewfinderBrush">
</VideoBrush>
</Canvas.Background>
</Canvas>
Here is my setup code from the .XAML.CS
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
if (PhotoCamera.IsCameraTypeSupported(CameraType.FrontFacing))
{
cam = new Microsoft.Devices.PhotoCamera(CameraType.FrontFacing);
}
else
{
cam = new Microsoft.Devices.PhotoCamera(CameraType.Primary);
}
cam.Initialized += new EventHandler<Microsoft.Devices.CameraOperationCompletedEventArgs>(cam_Initialized);
cam.CaptureCompleted += new EventHandler<CameraOperationCompletedEventArgs>(cam_CaptureCompleted);
cam.CaptureImageAvailable += new EventHandler<Microsoft.Devices.ContentReadyEventArgs>(cam_CaptureImageAvailable);
cam.CaptureThumbnailAvailable += new EventHandler<ContentReadyEventArgs>(cam_CaptureThumbnailAvailable);
viewfinderBrush.SetSource(cam);
}
The problem is that I hold the phone in Portrait and point the phone at a person. The screen shows the persons head on the right side of the screen and the persons feet at the left of the screen.
While as they stand in front of me there head should be at the top of the screen and there feet at the bottm, cause these people aint superman.
So it seems the image from the camera is getting rotated -90 before it appears on the screen.
Can anybody explain whats going wrong and what sample code I need to implement to fix this problem.
Thanks,
-Code
You need to implement a VideoBrush.RelativeTransform, as detailed in the following article :-
http://msdn.microsoft.com/en-us/magazine/hh708750.aspx
Also covered in the following :-
ViewFinder Orientation With Windows Phone 7 Mango PhotoCamera