diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2006-10-28 00:03:29 +0200 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2006-10-28 00:03:29 +0200 |
commit | 3863aa643f604f17b79684093fd34e7a67b093fa (patch) | |
tree | d36f5f54973a32185d02b207f8b1b5ad5b8f49f1 | |
parent | 8e2ebc4de19e6956549413a599f6e27daa498303 (diff) |
fix ImageMetaData classes
-rw-r--r-- | src/ExifImageMetaData.H | 2 | ||||
-rw-r--r-- | src/ExifImageMetaData.cxx | 11 | ||||
-rw-r--r-- | src/GipfelWidget.cxx | 58 | ||||
-rw-r--r-- | src/ImageMetaData.H | 2 | ||||
-rw-r--r-- | src/ImageMetaData.cxx | 16 | ||||
-rw-r--r-- | src/JpgcomImageMetaData.H | 2 | ||||
-rw-r--r-- | src/JpgcomImageMetaData.cxx | 3 | ||||
-rw-r--r-- | src/Makefile.am | 2 |
8 files changed, 58 insertions, 38 deletions
diff --git a/src/ExifImageMetaData.H b/src/ExifImageMetaData.H index bc567ff..dd17871 100644 --- a/src/ExifImageMetaData.H +++ b/src/ExifImageMetaData.H @@ -22,7 +22,7 @@ #include "ImageMetaData.H" -class ExifImageMetaData : ImageMetaData { +class ExifImageMetaData : public ImageMetaData { virtual int load_image(char *name); virtual int save_image(char *name); }; diff --git a/src/ExifImageMetaData.cxx b/src/ExifImageMetaData.cxx index 05a43d5..1ba215e 100644 --- a/src/ExifImageMetaData.cxx +++ b/src/ExifImageMetaData.cxx @@ -47,13 +47,13 @@ ExifImageMetaData::load_image(char *name) { if (p) { while (fgets(buf, sizeof(buf), p) != NULL) { - if (sscanf(buf, "%d\t%s", &id, val) != 2) { + if (sscanf(buf, "%x\t%s", &id, val) != 2) { continue; } - + switch(id) { case FOCAL_LENGTH_IN_35MM_FILM: - focallength_sensor_ratio = atof(val) / 35; + focallength_sensor_ratio = atof(val) / 35.0; break; } } @@ -68,3 +68,8 @@ ExifImageMetaData::load_image(char *name) { return 0; } + +int +ExifImageMetaData::save_image(char *name) { +} + diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index 75451ec..8314222 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -35,6 +35,8 @@ #include <FL/Fl_JPEG_Image.H> #include <FL/fl_draw.H> +#include "ExifImageMetaData.H" +#include "JpgcomImageMetaData.H" #include "Fl_Search_Chooser.H" #include "choose_hill.H" #include "util.h" @@ -76,14 +78,9 @@ GipfelWidget::GipfelWidget(int X,int Y,int W, int H): Fl_Widget(X, Y, W, H) { int GipfelWidget::load_image(char *file) { - char * args[32]; - FILE *p; - pid_t pid; - char buf[1024]; - double lo, la, he, dir, ni, ti, sc; - int status; - Projection::Projection_t pt = Projection::TANGENTIAL; Fl_Image *new_img; + ImageMetaData *md; + int ret; new_img = new Fl_JPEG_Image(file); @@ -112,32 +109,33 @@ GipfelWidget::load_image(char *file) { mb->add("Center Peak", 0, (Fl_Callback*) center_cb, this); // try to retrieve gipfel data from JPEG comment section - args[0] = "rdjpgcom"; - args[1] = file; - args[2] = NULL; - - p = pexecvp(args[0], args, &pid, "r"); - if (p) { - while (fgets(buf, sizeof(buf), p) != NULL) { - if (sscanf(buf, GIPFEL_FORMAT, &lo, &la, &he, &dir, &ni, &ti, &sc, &pt) >= 7) { - set_view_long(lo); - set_view_lat(la); - set_view_height(he); - set_center_angle(dir); - set_nick_angle(ni); - set_tilt_angle(ti); - set_scale(sc); - set_projection(pt); - - break; - } + md = new JpgcomImageMetaData(); + 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()); } - fclose(p); - waitpid(pid, &status, 0); - if (WEXITSTATUS(status) == 127 || WEXITSTATUS(status) == 126) { - fprintf(stderr, "%s not found\n", args[0]); + } + + delete md; + + if (ret == 1) { + md = new ExifImageMetaData(); + ret = md->load_image(file); + if (ret == 0) { + set_scale(md->get_focallength_sensor_ratio() * img->w()); } + delete md; } return 0; diff --git a/src/ImageMetaData.H b/src/ImageMetaData.H index 3349cab..1318e10 100644 --- a/src/ImageMetaData.H +++ b/src/ImageMetaData.H @@ -53,6 +53,6 @@ class ImageMetaData { void set_nick(double v); void set_tilt(double v); void set_focallength_sensor_ratio(double v); - int set_projection_type(int v); + void set_projection_type(int v); }; #endif diff --git a/src/ImageMetaData.cxx b/src/ImageMetaData.cxx index 0c868bd..745529b 100644 --- a/src/ImageMetaData.cxx +++ b/src/ImageMetaData.cxx @@ -33,6 +33,15 @@ ImageMetaData::ImageMetaData() { projection_type = -1; } +int +ImageMetaData::load_image(char *name) { + return 1; +} + +int +ImageMetaData::save_image(char *name) { + return 1; +} double ImageMetaData::get_longitude() { @@ -69,6 +78,10 @@ ImageMetaData::get_focallength_sensor_ratio() { return focallength_sensor_ratio; } +int +ImageMetaData::get_projection_type() { + return projection_type; +} void ImageMetaData::set_longitude(double v) { @@ -105,6 +118,7 @@ ImageMetaData::set_focallength_sensor_ratio(double v) { focallength_sensor_ratio = v; } -int ImageMetaData::set_projection_type(int v) { +void +ImageMetaData::set_projection_type(int v) { projection_type = v; } diff --git a/src/JpgcomImageMetaData.H b/src/JpgcomImageMetaData.H index 3d063c6..70e266e 100644 --- a/src/JpgcomImageMetaData.H +++ b/src/JpgcomImageMetaData.H @@ -22,7 +22,7 @@ #include "ImageMetaData.H" -class JpgcomImageMetaData : ImageMetaData { +class JpgcomImageMetaData : public ImageMetaData { virtual int load_image(char *name); virtual int save_image(char *name); }; diff --git a/src/JpgcomImageMetaData.cxx b/src/JpgcomImageMetaData.cxx index 39fb2b8..8dcd54e 100644 --- a/src/JpgcomImageMetaData.cxx +++ b/src/JpgcomImageMetaData.cxx @@ -91,3 +91,6 @@ JpgcomImageMetaData::load_image(char *name) { return ret; } +int +JpgcomImageMetaData::save_image(char *name) { +} diff --git a/src/Makefile.am b/src/Makefile.am index 4b54bc8..a730123 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -16,7 +16,7 @@ gipfel_SOURCES = \ OutputImage.cxx \ JPEGOutputImage.cxx \ TIFFOutputImage.cxx \ - PreviewOutputImage.cxx + PreviewOutputImage.cxx \ ImageMetaData.cxx \ JpgcomImageMetaData.cxx \ ExifImageMetaData.cxx |