How to use ExifInterface in xamarin android

2019-08-29 05:27发布

问题:

I am using the xamarin media plugin to save some pictures. The pictures are in JPEG file. What I want to do is edit comments attribute in image details. See picture.

image detail

I am looking at ExifInterface on following link. https://developer.android.com/reference/android/media/ExifInterface#TAG_COPYRIGHT

My first question is, which tag I am required to use in for comments. My second question is How shall I use SetAttribue() .

This is my code.

  private void Button_Clicked(object sender, EventArgs e)
    {
        Photo photo = new Photo()
        {
            Jobno =jobnoentry.Text,
            Applicationletter = Applicationletterentry,
            Signno = signnoentry.Text,
            Type = Phototypeentry,
            Notes = notesentry.Text,
        };

        using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_PATH))
        {
            conn.CreateTable<Photo>();
            var numberofrows = conn.Insert(photo);

            if(numberofrows > 0)
              DisplayAlert("Success","Photo has been saved successfully", "Great");
            else
                DisplayAlert("Failure","Error occoured while saving photo", "Try again");
        }
    }

    //edit image comment 
    public void setAttribute(String TAG_USER_COMMENT, String Applicationletterentry) { }




    private async void Take_Photo_Button_Clicked(object sender, EventArgs e)
    {
        await CrossMedia.Current.Initialize();
        if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
        {
            await DisplayAlert("No Camera", ":( No camera available.", "OK");
            return;
        }

        var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
        {
            SaveToAlbum = true,
            Name = jobnoentry.Text + "-" + Applicationletterentry + "-" + signnoentry.Text + "-" + Phototypeentry,

    });

        if (file == null)
            return;

        MainImage.Source = ImageSource.FromStream(() =>
        {
            var stream = file.GetStream();
            return stream;
        });


    }
}

This is the code I have got

//edit image comment 
        public void setAttribute(String TAG_USER_COMMENT, String Applicationletterentry) { }

Is this correct and where should I use this code.

Many Thanks.