diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/DataImage.cxx | 1 | ||||
-rw-r--r-- | src/GipfelWidget.cxx | 4 | ||||
-rw-r--r-- | src/Panorama.cxx | 25 | ||||
-rw-r--r-- | src/Stitch.H | 3 | ||||
-rw-r--r-- | src/Stitch.cxx | 22 | ||||
-rw-r--r-- | src/gipfel.cxx | 31 |
6 files changed, 74 insertions, 12 deletions
diff --git a/src/DataImage.cxx b/src/DataImage.cxx index c230ed1..f7109cd 100644 --- a/src/DataImage.cxx +++ b/src/DataImage.cxx @@ -30,6 +30,7 @@ DataImage::DataImage(int X, int Y, int W, int H): Fl_Widget(X, Y, W, H) { d = 3; data = (uchar*) malloc(W * H * d); + memset(data, 0, W * H * d); } DataImage::~DataImage() { diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index c6a5990..aac0b49 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -757,6 +757,8 @@ GipfelWidget::get_pixel(double a_view, double a_nick, } pan->get_coordinates(a_view, a_nick, &px, &py); - return DataImage::get_pixel(img, px, py, r, g, b); + +//printf("===> %s: %f, %f -> %d %d\n", img_file, a_view, a_nick, px, py); + return DataImage::get_pixel(img, px + img->w() / 2, py + img->h() / 2, r, g, b); } diff --git a/src/Panorama.cxx b/src/Panorama.cxx index 55fb9b8..b33a260 100644 --- a/src/Panorama.cxx +++ b/src/Panorama.cxx @@ -588,15 +588,28 @@ Panorama::get_real_distance(Hill *m) { int Panorama::get_coordinates(double a_view, double a_nick, int *x, int *y) { - Hill *m = new Hill(0,0); + Hill m(0,0); - m->a_view = a_view; - m->a_nick = a_nick; - proj->set_coordinates(m, &parms); - *x = m->x; - *y = m->y; + m.a_view = a_view - parms.a_center; + + if (m.a_view > pi_d) { + m.a_view -= 2.0*pi_d; + } else if (m.a_view < -pi_d) { + m.a_view += 2.0*pi_d; + } + + if (m.a_view < view_angle && m.a_view > - view_angle) { + return 1; + } + + m.a_nick = a_nick; + + proj->set_coordinates(&m, &parms); + + *x = m.x; + *y = m.y; return 0; } diff --git a/src/Stitch.H b/src/Stitch.H index 8c126f7..bc8436e 100644 --- a/src/Stitch.H +++ b/src/Stitch.H @@ -38,8 +38,7 @@ class Stitch { int load_image(char *file); int resample(DataImage *img, - double view_start, double view_end, - double nick_start, double nick_end); + double view_start, double view_end); }; #endif diff --git a/src/Stitch.cxx b/src/Stitch.cxx index ca63ed3..9080259 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -58,8 +58,26 @@ Stitch::load_image(char *file) { int Stitch::resample(DataImage *img, - double view_start, double view_end, - double nick_start, double nick_end) { + double view_start, double view_end) { + double step_view = (view_end - view_start) / img->w(); + char r, g, b; + int y_off = img->h() / 2; + for (int x=0; x<img->w(); x++) { + for (int y=0; y<img->h(); y++) { + double a_view, a_nick; + a_view = x * step_view; + a_nick = (y_off - y) * step_view; + + for (int i=0; i<MAX_PICS; i++) { + if (gipf[i] == NULL) { + break; + } else if (gipf[i]->get_pixel(a_view, a_nick, &r, &g, &b)==0) { + img->set_pixel(x, y, r, g, b); + break; + } + } + } + } } diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 4a284aa..8247d7d 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -41,6 +41,8 @@ #include "Fl_Value_Dial.H" #include "Fl_Search_Chooser.H" #include "GipfelWidget.H" +#include "DataImage.H" +#include "Stitch.H" #include "choose_hill.H" #include "../config.h" @@ -60,6 +62,8 @@ Fl_Value_Input *i_view_lat, *i_view_long, *i_view_height; Fl_Box *b_viewpoint; Fl_Menu_Bar *mb; +int stitch(int argc, char **argv); + void set_values() { s_center->value(gipf->get_center_angle()); s_nick->value(gipf->get_nick_angle()); @@ -319,12 +323,13 @@ int main(int argc, char** argv) { char c, *sep, *tmp, **my_argv; char *view_point = NULL; int err, bflag = 0, dflag = 0, my_argc; + int stitch_flag = 0; Fl_Window *control_win, *view_win; Fl_Scroll *scroll; err = 0; - while ((c = getopt(argc, argv, "d:v:")) != EOF) { + while ((c = getopt(argc, argv, "d:v:s")) != EOF) { switch (c) { case 'h': usage(); @@ -336,6 +341,9 @@ int main(int argc, char** argv) { case 'v': view_point = optarg; break; + case 's': + stitch_flag++; + break; default: err++; } @@ -361,6 +369,10 @@ int main(int argc, char** argv) { Fl::scheme("plastic"); } + if (stitch_flag) { + stitch(my_argc, my_argv); + } + control_win = create_control_window(); view_win = new Fl_Window(800, 600); @@ -398,3 +410,20 @@ int main(int argc, char** argv) { return Fl::run(); } + +int stitch(int argc, char **argv) { + Fl_Window *win; + Stitch *st = new Stitch(); + + st->load_image("test1.jpg"); + st->load_image("test2.jpg"); + st->load_image("test3.jpg"); + + win = new Fl_Window(0,0, 1000, 200); + DataImage *img = new DataImage(0, 0, 1000, 200); + st->resample(img, 2.0, 6.0); + + win->show(0, argv); + Fl::run(); + exit(0); +} |