Windows Phone camera gets picture is rotated 90°

Source: Internet
Author: User



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°


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.