summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dive.c9
-rw-r--r--dive.h4
-rw-r--r--qt-ui/profile/profilewidget2.cpp4
-rw-r--r--qthelper.cpp4
-rw-r--r--save-xml.c4
5 files changed, 13 insertions, 12 deletions
diff --git a/dive.c b/dive.c
index a04c92198..c1b5cae87 100644
--- a/dive.c
+++ b/dive.c
@@ -2283,13 +2283,14 @@ static bool new_picture_for_dive(struct dive *d, char *filename)
void dive_create_picture(struct dive *d, char *filename, int shift_time)
{
+ timestamp_t timestamp;
if (!new_picture_for_dive(d, filename))
return;
struct picture *p = alloc_picture();
p->filename = filename;
- picture_load_exif_data(p);
- if (p->timestamp)
- p->timestamp += shift_time;
+ picture_load_exif_data(p, &timestamp);
+ if (timestamp)
+ p->offset = timestamp - d->when + shift_time;
dive_add_picture(d, p);
dive_set_geodata_from_picture(d, p);
}
@@ -2298,7 +2299,7 @@ void dive_add_picture(struct dive *d, struct picture *newpic)
{
struct picture **pic_ptr = &d->picture_list;
/* let's keep the list sorted by time */
- while( *pic_ptr && (*pic_ptr)->timestamp < newpic->timestamp )
+ while( *pic_ptr && (*pic_ptr)->offset < newpic->offset )
pic_ptr = &(*pic_ptr)->next;
newpic->next = *pic_ptr;
*pic_ptr = newpic;
diff --git a/dive.h b/dive.h
index 279a2944c..23278d4a3 100644
--- a/dive.h
+++ b/dive.h
@@ -289,7 +289,7 @@ struct dive {
/* picture list and methods related to dive picture handling */
struct picture {
char *filename;
- time_t timestamp;
+ int32_t offset;
degrees_t latitude;
degrees_t longitude;
struct picture *next;
@@ -305,7 +305,7 @@ extern void dive_create_picture(struct dive *d, char *filename, int shift_time);
extern void dive_add_picture(struct dive *d, struct picture *newpic);
extern void dive_remove_picture(struct dive *d, struct picture *pic);
extern unsigned int dive_get_picture_count(struct dive *d);
-extern void picture_load_exif_data(struct picture *p);
+extern void picture_load_exif_data(struct picture *p, timestamp_t *timestamp);
extern void dive_set_geodata_from_picture(struct dive *d, struct picture *pic);
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 8374006bc..c709e9389 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -1307,13 +1307,13 @@ void ProfileWidget2::plotPictures()
struct picture *pic = (struct picture*) m->index(i,1).data(Qt::UserRole).value<void*>();
// it's a correct picture, but doesn't have a timestamp: only show on the widget near the
// information area.
- if (!pic->timestamp)
+ if (!pic->offset)
continue;
DivePictureItem *item = new DivePictureItem();
item->setPixmap(m->index(i,0).data(Qt::DecorationRole).value<QPixmap>());
// let's put the picture at the correct time, but at a fixed "depth" on the profile
// not sure this is ideal, but it seems to look right.
- x = timeAxis->posAtValue(pic->timestamp - current_dive->when);
+ x = timeAxis->posAtValue(pic->offset);
if (i == 0)
y = 10;
else
diff --git a/qthelper.cpp b/qthelper.cpp
index 1dd25e241..7eba936a6 100644
--- a/qthelper.cpp
+++ b/qthelper.cpp
@@ -264,7 +264,7 @@ extern "C" xsltStylesheetPtr get_stylesheet(const char *name)
return xslt;
}
-extern "C" void picture_load_exif_data(struct picture *p)
+extern "C" void picture_load_exif_data(struct picture *p, timestamp_t *timestamp)
{
EXIFInfo exif;
memblock mem;
@@ -273,7 +273,7 @@ extern "C" void picture_load_exif_data(struct picture *p)
goto picture_load_exit;
if (exif.parseFrom((const unsigned char *)mem.buffer, (unsigned)mem.size) != PARSE_EXIF_SUCCESS)
goto picture_load_exit;
- p->timestamp = exif.epoch();
+ *timestamp = exif.epoch();
p->longitude.udeg= lrint(1000000.0 * exif.GeoLocation.Longitude);
p->latitude.udeg = lrint(1000000.0 * exif.GeoLocation.Latitude);
picture_load_exit:
diff --git a/save-xml.c b/save-xml.c
index 17f463a93..037fc45cb 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -333,8 +333,8 @@ static void save_picture(struct membuffer *b, struct picture *pic)
put_string(b, " <picture filename='");
put_string(b, pic->filename);
put_string(b, "'");
- if (pic->timestamp)
- put_format(b, " timestamp='%ld'", pic->timestamp);
+ if (pic->offset)
+ put_format(b, " offset='%d'", pic->offset);
if (pic->latitude.udeg || pic->longitude.udeg) {
put_degrees(b, pic->latitude, " gps='", " ");
put_degrees(b, pic->longitude, "", "'");