16,555
社区成员
发帖
与我相关
我的任务
分享
Private Sub GetGPSTest()
Dim theImage As Image = New Bitmap("c:\test.jpg")
Dim propItems As PropertyItem() = theImage.PropertyItems '获取照片的PropertyItems
Dim propItem As PropertyItem
Dim value As Byte()
Dim d, m, s As Double
Dim Latitude As String
For Each propItem In propItems
If propItem.Id = &H2 Then '找到维度信息
value = propItem.Value '
d = BitConverter.ToUInt32(value, 0) / BitConverter.ToUInt32(value, 4) '读取度
m = BitConverter.ToUInt32(value, 8) / BitConverter.ToUInt32(value, 12) '读取分
s = BitConverter.ToUInt32(value, 16) / BitConverter.ToUInt32(value, 20) '读取秒
'结果为 31; 20; 20.706 其中秒只显示到小数点后三位
'但在windows中查看照片exif属性,能看到维度为31; 20; 20.706000000005673
'秒显示到小数点后15位,这个是怎么实现的
Latitude = String.Format("{0:#}; {1:#}; {2}", d, m, s)
End If
Next
End Sub