Frage

in windows phone how can I determine the orientation of the cameracapturetask or Photochoosertask?

   private void openCameraTask()
    {
        CameraCaptureTask cam = new CameraCaptureTask();
        cam.Completed += task_Completed;

        cam.Show();
    }

    void task_Completed(object sender, PhotoResult e)
    {
        if (e.TaskResult == TaskResult.OK)
        {

            imgFrame.Visibility = System.Windows.Visibility.Visible;
            System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();


            bmp.SetSource(e.ChosenPhoto);
            imgProfilePic.ImageSource = bmp;
         }
     }
War es hilfreich?

Lösung

A possible way is by checking the height and width of the image in pixels. If the height is higher than the width then you can say it's portrait or else landscape. The BitmapImage class has no method for telling you this right away.

Something as simple as

if (bitmap.PixelHeight > bitmap.PixelWidth) {
     // portrait 
} else {
     // landscape 
}

There´s also a possibility of both sizes being the same. So there's not really a landscape or portrait in this case.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top