summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2006-10-30 18:37:27 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2006-10-30 18:37:27 +0100
commit19bec8bde89fc08f6497a346b2121bcd96d1f528 (patch)
tree69b6677b273fc8062edfb70f2b38d545c56ad92d
parentda5192170bb7ed19a8eadbc8ac393b0fa222c7df (diff)
fix problem with compatibility code
-rw-r--r--src/GipfelWidget.cxx26
-rw-r--r--src/ImageMetaData.H3
-rw-r--r--src/ImageMetaData.cxx11
3 files changed, 19 insertions, 21 deletions
diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx
index 2efd231..a1982d5 100644
--- a/src/GipfelWidget.cxx
+++ b/src/GipfelWidget.cxx
@@ -104,23 +104,17 @@ GipfelWidget::load_image(char *file) {
mb->box(FL_NO_BOX);
mb->add("Center Peak", 0, (Fl_Callback*) center_cb, this);
- // try to retrieve gipfel data from JPEG comment section
+ // try to retrieve gipfel data from JPEG meta data
md = new ImageMetaData();
- ret = md->load_image(file);
- if (ret != 1) {
- set_view_long(md->get_longitude());
- set_view_lat(md->get_latitude());
- set_view_height(md->get_height());
- set_center_angle(md->get_direction());
- set_nick_angle(md->get_nick());
- set_tilt_angle(md->get_tilt());
- set_projection((Projection::Projection_t) md->get_projection_type());
- if (ret == 2) { // special compatibility return code for old format
- set_scale(md->get_focallength_sensor_ratio());
- } else {
- set_scale(md->get_focallength_sensor_ratio() * img->w());
- }
- }
+ md->load_image(file, img->w());
+ set_view_long(md->get_longitude());
+ set_view_lat(md->get_latitude());
+ set_view_height(md->get_height());
+ set_center_angle(md->get_direction());
+ set_nick_angle(md->get_nick());
+ set_tilt_angle(md->get_tilt());
+ set_projection((Projection::Projection_t) md->get_projection_type());
+ set_scale(md->get_focallength_sensor_ratio() * img->w());
delete md;
diff --git a/src/ImageMetaData.H b/src/ImageMetaData.H
index 442aaef..7116d98 100644
--- a/src/ImageMetaData.H
+++ b/src/ImageMetaData.H
@@ -29,6 +29,7 @@ class ImageMetaData {
double nick;
double tilt;
double focallength_sensor_ratio;
+ double scale;
int projection_type;
int load_image_jpgcom(char *name);
@@ -38,7 +39,7 @@ class ImageMetaData {
public:
ImageMetaData();
- int load_image(char *name);
+ int load_image(char *name, int img_width);
int save_image(char *in_img, char *out_img);
double get_longitude();
diff --git a/src/ImageMetaData.cxx b/src/ImageMetaData.cxx
index 424a792..d78493d 100644
--- a/src/ImageMetaData.cxx
+++ b/src/ImageMetaData.cxx
@@ -38,16 +38,19 @@ ImageMetaData::ImageMetaData() {
nick = 0.0;
tilt = 0.0;
focallength_sensor_ratio = 1.0;
- projection_type = 1;
+ scale = NAN;
+ projection_type = 0;
}
int
-ImageMetaData::load_image(char *name) {
+ImageMetaData::load_image(char *name, int img_width) {
int ret;
ret = load_image_jpgcom(name);
- if (ret != 0) {
+ if (ret == 2) { // old format
+ focallength_sensor_ratio = scale / (double) img_width;
+ } else if (ret == 1) { // get reasonable defaults from exif data
ret = load_image_exif(name);
}
@@ -179,7 +182,7 @@ ImageMetaData::load_image_jpgcom(char *name) {
direction = dir;
nick = ni;
tilt = ti;
- focallength_sensor_ratio = fr;
+ scale = fr;
projection_type = pt;
ret = 2; // special return value for compatibility with