Commit a210d8d4 authored by Andreas Bircher's avatar Andreas Bircher

casting to unsigned chars

parent 0ea21917
...@@ -15,8 +15,8 @@ ExifParser::~ExifParser() ...@@ -15,8 +15,8 @@ ExifParser::~ExifParser()
double ExifParser::readTime(QByteArray& buf) double ExifParser::readTime(QByteArray& buf)
{ {
char tiffHeader[] = {static_cast<char>(0x49),static_cast<char>(0x49),static_cast<char>(0x2A),static_cast<char>(0x00)}; QByteArray tiffHeader("\x49\x49\x2A", 3);
char createDateHeader[] = {static_cast<char>(0x04),static_cast<char>(0x90),static_cast<char>(0x02),static_cast<char>(0x00)}; QByteArray createDateHeader("\x04\x90\x02", 3);
// find header position // find header position
uint32_t tiffHeaderIndex = buf.indexOf(tiffHeader); uint32_t tiffHeaderIndex = buf.indexOf(tiffHeader);
...@@ -58,14 +58,12 @@ double ExifParser::readTime(QByteArray& buf) ...@@ -58,14 +58,12 @@ double ExifParser::readTime(QByteArray& buf)
bool ExifParser::write(QByteArray &buf, QGeoCoordinate coordinate) bool ExifParser::write(QByteArray &buf, QGeoCoordinate coordinate)
{ {
QByteArray app1Header; QByteArray app1Header("\xff\xe1", 2);
app1Header.append(0xff);
app1Header.append(0xe1);
uint32_t app1HeaderInd = buf.indexOf(app1Header); uint32_t app1HeaderInd = buf.indexOf(app1Header);
uint16_t *conversionPointer = reinterpret_cast<uint16_t *>(buf.mid(app1HeaderInd + 2, 2).data()); uint16_t *conversionPointer = reinterpret_cast<uint16_t *>(buf.mid(app1HeaderInd + 2, 2).data());
uint16_t app1Size = *conversionPointer; uint16_t app1Size = *conversionPointer;
uint16_t app1SizeEndian = qFromBigEndian(app1Size) + 0xa5; // change wrong endian uint16_t app1SizeEndian = qFromBigEndian(app1Size) + 0xa5; // change wrong endian
char tiffHeader[4] = {0x49, 0x49, 0x2A, 0x00}; QByteArray tiffHeader("\x49\x49\x2A", 3);
uint32_t tiffHeaderInd = buf.indexOf(tiffHeader); uint32_t tiffHeaderInd = buf.indexOf(tiffHeader);
conversionPointer = reinterpret_cast<uint16_t *>(buf.mid(tiffHeaderInd + 8, 2).data()); conversionPointer = reinterpret_cast<uint16_t *>(buf.mid(tiffHeaderInd + 8, 2).data());
uint16_t numberOfTiffFields = *conversionPointer; uint16_t numberOfTiffFields = *conversionPointer;
...@@ -125,7 +123,11 @@ bool ExifParser::write(QByteArray &buf, QGeoCoordinate coordinate) ...@@ -125,7 +123,11 @@ bool ExifParser::write(QByteArray &buf, QGeoCoordinate coordinate)
gpsIFDInd.i = nextIfdOffset; gpsIFDInd.i = nextIfdOffset;
// this will stay constant // this will stay constant
char gpsInfo[12] = {static_cast<char>(0x25), static_cast<char>(0x88), static_cast<char>(0x04), static_cast<char>(0x00), static_cast<char>(0x01), static_cast<char>(0x00), static_cast<char>(0x00), static_cast<char>(0x00), static_cast<char>(gpsIFDInd.c[0]), static_cast<char>(gpsIFDInd.c[1]), static_cast<char>(gpsIFDInd.c[2]), static_cast<char>(gpsIFDInd.c[3])}; QByteArray gpsInfo("\x25\x88\x04\x00\x01\x00\x00\x00", 8);
gpsInfo.append(gpsIFDInd.c[0]);
gpsInfo.append(gpsIFDInd.c[1]);
gpsInfo.append(gpsIFDInd.c[2]);
gpsInfo.append(gpsIFDInd.c[3]);
// filling values to gpsData // filling values to gpsData
uint32_t gpsDataExtInd = gpsIFDInd.i + 2 + sizeof(fields_s); uint32_t gpsDataExtInd = gpsIFDInd.i + 2 + sizeof(fields_s);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment