As I said in my last essay, the photo taken by Windows Phone is reversed by 90° if used directly.
Studied for a long time. Finally found the problem. In fact.. This is the use of habit problems ...
The photo obtained by Cameracaptureui is actually based on the direction of the 2nd chart level. Why would I say that? Let's take a look at the photo taken with the simulator. Notice that the words on the left are not.
Give another level, you can see more clearly. YUY2 (640x480)
Plainly.. In fact, the level is what other foreigners think of the default perspective. But someone said. This way. When the portrait is taken, it will be displayed sideways. It's strange. Not afraid of fear. In fact, we find the law. The resulting stream can be processed.
Here is the code
public static async Task RotateCaptureImageByDisplayInformationAutoRotationPreferences(IRandomAccessStream inStream, IRandomAccessStream outStream)
{
BitmapDecoder decoder = await BitmapDecoder.CreateAsync(inStream);
BitmapEncoder encoder = await BitmapEncoder.CreateForTranscodingAsync(outStream, decoder); var ort = DisplayInformation.GetForCurrentView().CurrentOrientation;
Debug.WriteLine(ort); switch (ort)
{ //The same as Portrait case DisplayOrientations.None:
encoder.BitmapTransform.Rotation = BitmapRotation.Clockwise90Degrees; break; //The default view for capture. case DisplayOrientations.Landscape:
encoder.BitmapTransform.Rotation = BitmapRotation.None; break; case DisplayOrientations.Portrait:
encoder.BitmapTransform.Rotation = BitmapRotation.Clockwise90Degrees; break; case DisplayOrientations.LandscapeFlipped:
encoder.BitmapTransform.Rotation = BitmapRotation.Clockwise180Degrees; break; case DisplayOrientations.PortraitFlipped:
encoder.BitmapTransform.Rotation = BitmapRotation.Clockwise270Degrees; break; default: break;
} await encoder.FlushAsync();
}
With it. Mother is no longer afraid. Wait until the picture is rotated 90°. Ha ha haha
Windows Phone camera gets picture is rotated 90°