locked
Reading GPS data from JPEG image in WPF app windows 8.1

    Question

  • Hi,

    I am developing a Windows 8.1 application using c# xaml wherein I am trying to extract latitude and longitude information from a JPEG image. I am not able extract this information. The code is as given below. please advise. Thanks you..

    var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read); var bitmapImage = new Windows.UI.Xaml.Media.Imaging.BitmapImage(); await bitmapImage.SetSourceAsync(stream); myImage.Source = bitmapImage; var decoder = await Windows.Graphics.Imaging.BitmapDecoder.CreateAsync(stream); requests.Add("System.GPS.Latitude");

    var retrievedProps =await decoder.BitmapProperties.GetPropertiesAsync(requests);

    ushort latitude;

    if (retrievedProps.ContainsKey("System.GPS.Latitude"))

    {

    latitude = (ushort)retrievedProps["System.GPS.Latitude"].Value;

    latitudetxt.Text =Convert.ToString(latitude); }




    Friday, May 2, 2014 8:55 PM

Answers

  • Hi,

    You can refer to some codes below:

    m_imageProperties = await file.Properties.GetImagePropertiesAsync();
    
                    string[] requests =
                    {
                        "System.GPS.Latitude",        
                        "System.GPS.Longitude"          
                    };
    
                    IDictionary<string, object> retrievedProps =
                        await m_imageProperties.RetrievePropertiesAsync(requests);
     if (retrievedProps.ContainsKey("System.GPS.Latitude"))        
                {
                    latitude= ((ushort)retrievedProps["System.GPS.Latitude"]).ToString();
                }
      if (retrievedProps.ContainsKey("System.GPS.Longitude"))
                {
                    fNumberText = ((ushort)retrievedProps["System.GPS.Longitude"]).ToString();
                }

    And you can refer to the sample below:

    http://code.msdn.microsoft.com/windowsapps/Simple-Imaging-Sample-a2dec2b0/sourcecode?fileId=58515&pathId=195614992

    In the Scenario1_ImageProperties.xaml.cs file there are two methods you can refer to get the image file GPS data:

    LoadFileAsync

    GetImagePropertiesForDisplay

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, May 5, 2014 2:51 AM