16,472
社区成员
发帖
与我相关
我的任务
分享
Image* pImg = Image::FromFile(_T("F:\\多媒体素材\\Photos\\IMG_0166.JPG"), FALSE);
if (pImg) {
PropertyItem* propertyItem = NULL;
UINT size = pImg->GetPropertyItemSize(PropertyTagGpsLatitudeRef);
if (size) {
propertyItem = (PropertyItem*)malloc(size);
if (propertyItem) {
Status stGet = pImg->GetPropertyItem(PropertyTagGpsLatitudeRef, size, propertyItem);
if ((stGet == Status::Ok) && (propertyItem->value)) {
char* pValue = (char*)propertyItem->value;//注意这里,不同的属性强转的类型也不同
}
delete propertyItem;
propertyItem = NULL;
}
}
delete pImg;
pImg = NULL;
}
其中PropertyTagGpsLatitudeRef在gdiplusimaging.h中有定义,还有很多很多,而楼主需要的GPS相关的就多达31种:
#define PropertyTagGpsVer 0x0000
#define PropertyTagGpsLatitudeRef 0x0001
#define PropertyTagGpsLatitude 0x0002
#define PropertyTagGpsLongitudeRef 0x0003
#define PropertyTagGpsLongitude 0x0004
#define PropertyTagGpsAltitudeRef 0x0005
#define PropertyTagGpsAltitude 0x0006
#define PropertyTagGpsGpsTime 0x0007
#define PropertyTagGpsGpsSatellites 0x0008
#define PropertyTagGpsGpsStatus 0x0009
#define PropertyTagGpsGpsMeasureMode 0x00A
#define PropertyTagGpsGpsDop 0x000B // Measurement precision
#define PropertyTagGpsSpeedRef 0x000C
#define PropertyTagGpsSpeed 0x000D
#define PropertyTagGpsTrackRef 0x000E
#define PropertyTagGpsTrack 0x000F
#define PropertyTagGpsImgDirRef 0x0010
#define PropertyTagGpsImgDir 0x0011
#define PropertyTagGpsMapDatum 0x0012
#define PropertyTagGpsDestLatRef 0x0013
#define PropertyTagGpsDestLat 0x0014
#define PropertyTagGpsDestLongRef 0x0015
#define PropertyTagGpsDestLong 0x0016
#define PropertyTagGpsDestBearRef 0x0017
#define PropertyTagGpsDestBear 0x0018
#define PropertyTagGpsDestDistRef 0x0019
#define PropertyTagGpsDestDist 0x001A
#define PropertyTagGpsProcessingMethod 0x001B
#define PropertyTagGpsAreaInformation 0x001C
#define PropertyTagGpsDate 0x001D
#define PropertyTagGpsDifferential 0x001E
最后附上PropertyItem的定义以及属性的数据类型的定义:
//---------------------------------------------------------------------------
// Property Item
//---------------------------------------------------------------------------
class PropertyItem
{
public:
PROPID id; // ID of this property
ULONG length; // Length of the property value, in bytes
WORD type; // Type of the value, as one of TAG_TYPE_XXX
// defined above
VOID* value; // property value
};
//---------------------------------------------------------------------------
// Image property types
//---------------------------------------------------------------------------
#define PropertyTagTypeByte 1
#define PropertyTagTypeASCII 2
#define PropertyTagTypeShort 3
#define PropertyTagTypeLong 4
#define PropertyTagTypeRational 5
#define PropertyTagTypeUndefined 7
#define PropertyTagTypeSLONG 9
#define PropertyTagTypeSRational 10