Какое пространство имен мне нужно включить для доступа к тегу Image exif? - PullRequest
0 голосов
/ 22 марта 2020

Я нашел несколько кодов для обработки ориентации изображения, все они должны получить доступ к свойствам / методам класса Image: PropertyIdList, ExifOrientationTag, GetPropertyItem, RotateFlip, RotateFlipType, но Visual Studio, похоже, не распознает эти свойства / методы из класса Image:

  • «Изображение» не содержит определения для PropertyIdList и не удалось найти какой-либо метод расширения ...

  • Имя ExifOrientationTag делает не существует в текущем контексте

  • «RotateFlip» не содержит определения для PropertyIdList и не удалось найти какой-либо метод расширения ...

  • Имя RotateFlipType не существует в текущем контексте

Я подозреваю, что я включаю неправильное пространство имен для класса Image:

using System;
using Xamarin.Forms; // this have Image, maybe I have to use another namespace?

public static class NormalizeImg
{

        public static void NormalizeOrientation(this Image image)
        {
            if (Array.IndexOf(image.PropertyIdList, ExifOrientationTagId) > -1)
            {
                int orientation;

                orientation = image.GetPropertyItem(ExifOrientationTagId).Value[0];

                if (orientation >= 1 && orientation <= 8)
                {
                    switch (orientation)
                    {
                        case 2:
                            image.RotateFlip(RotateFlipType.RotateNoneFlipX);
                            break;
                        case 3:
                            image.RotateFlip(RotateFlipType.Rotate180FlipNone);
                            break;
                        case 4:
                            image.RotateFlip(RotateFlipType.Rotate180FlipX);
                            break;
                        case 5:
                            image.RotateFlip(RotateFlipType.Rotate90FlipX);
                            break;
                        case 6:
                            image.RotateFlip(RotateFlipType.Rotate90FlipNone);
                            break;
                        case 7:
                            image.RotateFlip(RotateFlipType.Rotate270FlipX);
                            break;
                        case 8:
                            image.RotateFlip(RotateFlipType.Rotate270FlipNone);
                            break;
                    }

                    image.RemovePropertyItem(ExifOrientationTagId);
                }
            }
        }
    }
...