QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
ExifUtility.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QByteArray>
4#include <QtCore/QDateTime>
5#include <QtCore/QLoggingCategory>
6#include <QtCore/QString>
7
8#include <libexif/exif-data.h>
9
10Q_DECLARE_LOGGING_CATEGORY(ExifUtilityLog)
11
12namespace ExifUtility
13{
14
15// ============================================================================
16// EXIF Data Management
17// ============================================================================
18
21ExifData* loadFromBuffer(const QByteArray &buffer);
22
25ExifData* createNew();
26
32bool saveToBuffer(ExifData *data, QByteArray &buffer);
33
35bool isJpeg(const QByteArray &buffer);
36
39bool isTiff(const QByteArray &buffer);
40
42bool hasExifData(const QByteArray &buffer);
43
44// ============================================================================
45// Tag Reading Helpers
46// ============================================================================
47
49QString readString(ExifData *data, ExifTag tag, ExifIfd ifd = EXIF_IFD_0);
50
52int readShort(ExifData *data, ExifTag tag, ExifIfd ifd = EXIF_IFD_0);
53
55double readRational(ExifData *data, ExifTag tag, ExifIfd ifd = EXIF_IFD_0);
56
57// ============================================================================
58// Tag Writing Helpers
59// ============================================================================
60
64ExifEntry* initTag(ExifData *data, ExifIfd ifd, ExifTag tag);
65
69ExifEntry* createTag(ExifData *data, ExifIfd ifd, ExifTag tag, ExifFormat format, unsigned long components);
70
71// ============================================================================
72// GPS Coordinate Helpers
73// ============================================================================
74
76double gpsRationalToDecimal(ExifEntry *entry, ExifByteOrder order);
77
79void writeGpsCoordinate(ExifEntry *entry, ExifByteOrder order, double value);
80
82void writeRational(ExifEntry *entry, ExifByteOrder order, double value, int denominator = 100);
83
85void writeGpsRef(ExifEntry *entry, char value);
86
88void writeGpsAltRef(ExifEntry *entry, unsigned char value);
89
90// ============================================================================
91// DateTime Helpers
92// ============================================================================
93
98bool writeDateTimeOriginal(ExifData *data, const QDateTime &dateTime);
99
100} // namespace ExifUtility
Q_DECLARE_LOGGING_CATEGORY(AndroidSerialLog)
ExifEntry * initTag(ExifData *data, ExifIfd ifd, ExifTag tag)
double readRational(ExifData *data, ExifTag tag, ExifIfd ifd)
Read a rational value from an EXIF tag.
void writeGpsAltRef(ExifEntry *entry, unsigned char value)
Write a byte value to a GPS altitude reference entry (0=above, 1=below sea level)
bool isTiff(const QByteArray &buffer)
ExifEntry * createTag(ExifData *data, ExifIfd ifd, ExifTag tag, ExifFormat format, unsigned long components)
ExifData * loadFromBuffer(const QByteArray &buffer)
void writeGpsCoordinate(ExifEntry *entry, ExifByteOrder order, double value)
Write GPS coordinate as EXIF rationals (degrees, minutes, seconds)
void writeRational(ExifEntry *entry, ExifByteOrder order, double value, int denominator)
Write a single rational value to an entry.
bool writeDateTimeOriginal(ExifData *data, const QDateTime &dateTime)
bool hasExifData(const QByteArray &buffer)
Check if a buffer contains valid JPEG with EXIF data.
QString readString(ExifData *data, ExifTag tag, ExifIfd ifd)
Read a string value from an EXIF tag.
bool isJpeg(const QByteArray &buffer)
Check if a buffer is a JPEG image (starts with 0xFF 0xD8)
bool saveToBuffer(ExifData *data, QByteArray &buffer)
double gpsRationalToDecimal(ExifEntry *entry, ExifByteOrder order)
Convert GPS coordinate from EXIF rational format (deg/min/sec) to decimal degrees.
ExifData * createNew()
void writeGpsRef(ExifEntry *entry, char value)
Write an ASCII character to a GPS reference entry (N/S/E/W)
int readShort(ExifData *data, ExifTag tag, ExifIfd ifd)
Read a short (16-bit) value from an EXIF tag.