19 мар. 2014 г.

 Из-за того что кое-кто (не будем показывать пальцем, но это была компания Майкрософт) не озаботился созданием удобств для работы кухарок с exif свойствами фотографий в .NET, доставать GPS координаты из них приходится вот таким способом:   

Dim theImage As Image = New Bitmap("C:\Users\a.scherbakov\Documents\WP_000336.JPG")

Dim LatDegrees = BitConverter.ToUInt32(theImage.GetPropertyItem(2).Value(), 0) / CSng(BitConverter.ToUInt32(theImage.GetPropertyItem(2).Value(), 4))
Dim LatMinutes = BitConverter.ToUInt32(theImage.GetPropertyItem(2).Value(), 8) / CSng(BitConverter.ToUInt32(theImage.GetPropertyItem(2).Value(), 12))
Dim LatSeconds
If Not BitConverter.ToUInt32(theImage.GetPropertyItem(2).Value(), 16) / CSng(BitConverter.ToUInt32(theImage.GetPropertyItem(2).Value(), 20)) = 0 Then
LatSeconds = BitConverter.ToUInt32(theImage.GetPropertyItem(2).Value(), 16) / CSng(BitConverter.ToUInt32(theImage.GetPropertyItem(2).Value(), 20))
Else
 LatSeconds = (LatMinutes - Int(LatMinutes)) * 60
 
 
End If

Dim Latitude = LatDegrees & "° " & Int(LatMinutes) & "' " & LatSeconds



 
Dim LongDegrees = BitConverter.ToUInt32(theImage.GetPropertyItem(4).Value(), 0) / CSng(BitConverter.ToUInt32(theImage.GetPropertyItem(4).Value(), 4))

Dim LongMinutes = BitConverter.ToUInt32(theImage.GetPropertyItem(4).Value(), 8) / CSng(BitConverter.ToUInt32(theImage.GetPropertyItem(4).Value(), 12))
Dim LongSeconds
If Not BitConverter.ToUInt32(theImage.GetPropertyItem(4).Value(), 16) / CSng(BitConverter.ToUInt32(theImage.GetPropertyItem(4).Value(), 20)) = 0 Then
LongSeconds = BitConverter.ToUInt32(theImage.GetPropertyItem(4).Value(), 16) / CSng(BitConverter.ToUInt32(theImage.GetPropertyItem(4).Value(), 20))
Else
LongSeconds = (LongMinutes - Int(LongMinutes)) * 60
End If

Dim Longtitude = LongDegrees & "° " & Int(LongMinutes) & "' " & LongSeconds

Комментариев нет:

Отправить комментарий