From 8483acb33c613e596bb8ffc8ab5677ff5a168a7b Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sat, 24 Jun 2006 19:54:31 +0200 Subject: add Stitch files --- src/Stich.H | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/Stich.cxx | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 src/Stich.H create mode 100644 src/Stich.cxx (limited to 'src') diff --git a/src/Stich.H b/src/Stich.H new file mode 100644 index 0000000..86b8f8f --- /dev/null +++ b/src/Stich.H @@ -0,0 +1,44 @@ +// +// Copyright 2005 by Johannes Hofmann +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// + +#ifndef STITCH_H +#define STITCH_H + +#include "GipfelWidget.H" + +#define MAX_PICS 256 + +class Stitch { + private: + GipfelWidget *gipf[MAX_PICS]; + + + public: + Stitch(); + + ~Stitch(); + + int add_image(const char *file); + + int resample(Fl_RGB_Image *, + double view_start, double view_end, + double nick_start, double nick_end); +}; + +#endif diff --git a/src/Stich.cxx b/src/Stich.cxx new file mode 100644 index 0000000..0cfa4b5 --- /dev/null +++ b/src/Stich.cxx @@ -0,0 +1,43 @@ +// +// Stitch routines. +// +// Copyright 2006 by Johannes Hofmann +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// + +#include +#include +#include +#include + +#include "Stitch.H" + +Stitch::Stitch() { + + +} + +Stitch::~Stitch() { + + +} + + +int +Stitch::resample(Fl_Stitch_Display * + +} -- cgit v1.2.3 From c58cf1232ea3134671d632dcba651fbf11eb0155 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sat, 24 Jun 2006 20:09:24 +0200 Subject: add DataImage class stub --- src/DataImage.H | 37 +++++++++++++++++++++++++++++++++++++ src/DataImage.cxx | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 src/DataImage.H create mode 100644 src/DataImage.cxx (limited to 'src') diff --git a/src/DataImage.H b/src/DataImage.H new file mode 100644 index 0000000..abeb4f5 --- /dev/null +++ b/src/DataImage.H @@ -0,0 +1,37 @@ +// +// Copyright 2006 by Johannes Hofmann +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// + +#ifndef DATAIMAGE_H +#define DATAIMAGE_H + + + +class DataImage : Fl_Widget { + private: + + + public: + DataImage(int w, int h); + + ~DataImage(); + + int set_pixel(nt x, int y, char r, char g, char b); +}; + +#endif diff --git a/src/DataImage.cxx b/src/DataImage.cxx new file mode 100644 index 0000000..83881ff --- /dev/null +++ b/src/DataImage.cxx @@ -0,0 +1,41 @@ +// +// DataImage routines. +// +// Copyright 2006 by Johannes Hofmann +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// + +#include +#include +#include +#include + +#include "DataImage.H" + +DataImage::DataImage() { + + +} + +DataImage::~DataImage() { + +} + + +int +DataImage::set_pixel(int x, int y, char r, char g, char b) { +} -- cgit v1.2.3 From 8717d1dd411e7859a29e097e893956521bd1cd70 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sun, 25 Jun 2006 09:51:23 +0200 Subject: import image data grabbing from http://seriss.com/people/erco/fltk/#Fl_Image --- src/DataImage.H | 3 +++ src/DataImage.cxx | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) (limited to 'src') diff --git a/src/DataImage.H b/src/DataImage.H index abeb4f5..99910e5 100644 --- a/src/DataImage.H +++ b/src/DataImage.H @@ -32,6 +32,9 @@ class DataImage : Fl_Widget { ~DataImage(); int set_pixel(nt x, int y, char r, char g, char b); + + static int get_pixel(Fl_RGB_Image *img, int x, int y, + char *r, char *g, char *b); }; #endif diff --git a/src/DataImage.cxx b/src/DataImage.cxx index 83881ff..0775068 100644 --- a/src/DataImage.cxx +++ b/src/DataImage.cxx @@ -39,3 +39,49 @@ DataImage::~DataImage() { int DataImage::set_pixel(int x, int y, char r, char g, char b) { } + +static int +DataImage::get_pixel(Fl_RGB_Image *img, int x, int y, + char *r, char *g, char *b) { + if ( img->d() == 0 ) { + return 1; + } + + if (x < 0 || x >=img->w() || y < 0 || y >= img->h()) { + return 1; + } + + long index = (y * img->w() * img->d()) + (x * img->d()); // X/Y -> buf index + switch ( img->count() ) { + case 1: { // bitmap + const char *buf = img->data()[0]; + switch ( img->d() ) { + case 1: { // 8bit + *r = *g = *b = *(buf+index); + break; + } + case 3: // 24bit + *r = *(buf+index+0); + *g = *(buf+index+1); + *b = *(buf+index+2); + break; + default: // ?? + printf("Not supported: chans=%d\n", img->d()); + return 1; + } + break; + } + default: // ?? pixmap, bit vals + printf("Not supported: count=%d\n", img->count()); + exit(1); + } + + return 0; +} + + + + + + + -- cgit v1.2.3 From 8b9902ac6e239bd36681a2997ee1bdfa4239a5d8 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sun, 25 Jun 2006 09:54:28 +0200 Subject: Stich -> Stitch and hook new files in Makefile.am --- src/Makefile.am | 6 +++++- src/Stich.H | 44 -------------------------------------------- src/Stich.cxx | 43 ------------------------------------------- src/Stitch.H | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/Stitch.cxx | 43 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 92 insertions(+), 88 deletions(-) delete mode 100644 src/Stich.H delete mode 100644 src/Stich.cxx create mode 100644 src/Stitch.H create mode 100644 src/Stitch.cxx (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index e9e32f7..e8b384a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,7 +11,9 @@ gipfel_SOURCES = \ Hill.cxx \ Fl_Value_Dial.cxx \ Fl_Search_Chooser.cxx \ - choose_hill.cxx + choose_hill.cxx \ + Stitch.cxx \ + DataImage.cxx noinst_HEADERS = \ GipfelWidget.H \ @@ -24,4 +26,6 @@ noinst_HEADERS = \ Fl_Value_Dial.H \ Fl_Search_Chooser.H \ choose_hill.H \ + Stitch.H \ + DataImage.H \ util.h diff --git a/src/Stich.H b/src/Stich.H deleted file mode 100644 index 86b8f8f..0000000 --- a/src/Stich.H +++ /dev/null @@ -1,44 +0,0 @@ -// -// Copyright 2005 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// - -#ifndef STITCH_H -#define STITCH_H - -#include "GipfelWidget.H" - -#define MAX_PICS 256 - -class Stitch { - private: - GipfelWidget *gipf[MAX_PICS]; - - - public: - Stitch(); - - ~Stitch(); - - int add_image(const char *file); - - int resample(Fl_RGB_Image *, - double view_start, double view_end, - double nick_start, double nick_end); -}; - -#endif diff --git a/src/Stich.cxx b/src/Stich.cxx deleted file mode 100644 index 0cfa4b5..0000000 --- a/src/Stich.cxx +++ /dev/null @@ -1,43 +0,0 @@ -// -// Stitch routines. -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// - -#include -#include -#include -#include - -#include "Stitch.H" - -Stitch::Stitch() { - - -} - -Stitch::~Stitch() { - - -} - - -int -Stitch::resample(Fl_Stitch_Display * - -} diff --git a/src/Stitch.H b/src/Stitch.H new file mode 100644 index 0000000..86b8f8f --- /dev/null +++ b/src/Stitch.H @@ -0,0 +1,44 @@ +// +// Copyright 2005 by Johannes Hofmann +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// + +#ifndef STITCH_H +#define STITCH_H + +#include "GipfelWidget.H" + +#define MAX_PICS 256 + +class Stitch { + private: + GipfelWidget *gipf[MAX_PICS]; + + + public: + Stitch(); + + ~Stitch(); + + int add_image(const char *file); + + int resample(Fl_RGB_Image *, + double view_start, double view_end, + double nick_start, double nick_end); +}; + +#endif diff --git a/src/Stitch.cxx b/src/Stitch.cxx new file mode 100644 index 0000000..0cfa4b5 --- /dev/null +++ b/src/Stitch.cxx @@ -0,0 +1,43 @@ +// +// Stitch routines. +// +// Copyright 2006 by Johannes Hofmann +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// + +#include +#include +#include +#include + +#include "Stitch.H" + +Stitch::Stitch() { + + +} + +Stitch::~Stitch() { + + +} + + +int +Stitch::resample(Fl_Stitch_Display * + +} -- cgit v1.2.3 From 7d900b4ede22215413e4a0ddd1675c650ba3225f Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sun, 25 Jun 2006 11:49:32 +0200 Subject: implement various helper methods --- src/DataImage.H | 15 ++++++++++----- src/DataImage.cxx | 29 +++++++++++++++++++++++------ src/GipfelWidget.H | 3 +++ src/GipfelWidget.cxx | 17 +++++++++++++++++ src/Panorama.H | 2 ++ src/Panorama.cxx | 15 +++++++++++++++ src/Stitch.H | 5 +++-- src/Stitch.cxx | 30 ++++++++++++++++++++++++++---- 8 files changed, 99 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/DataImage.H b/src/DataImage.H index 99910e5..fe6200d 100644 --- a/src/DataImage.H +++ b/src/DataImage.H @@ -20,20 +20,25 @@ #ifndef DATAIMAGE_H #define DATAIMAGE_H +#include +#include - -class DataImage : Fl_Widget { +class DataImage : public Fl_Widget { private: + int d; + uchar *data; public: - DataImage(int w, int h); + DataImage(int X, int Y, int W, int H); ~DataImage(); - int set_pixel(nt x, int y, char r, char g, char b); + int set_pixel(int x, int y, char r, char g, char b); + + void draw(); - static int get_pixel(Fl_RGB_Image *img, int x, int y, + static int get_pixel(Fl_Image *img, int x, int y, char *r, char *g, char *b); }; diff --git a/src/DataImage.cxx b/src/DataImage.cxx index 0775068..c230ed1 100644 --- a/src/DataImage.cxx +++ b/src/DataImage.cxx @@ -22,13 +22,14 @@ #include #include #include -#include -#include "DataImage.H" - -DataImage::DataImage() { +#include +#include "DataImage.H" +DataImage::DataImage(int X, int Y, int W, int H): Fl_Widget(X, Y, W, H) { + d = 3; + data = (uchar*) malloc(W * H * d); } DataImage::~DataImage() { @@ -38,10 +39,26 @@ DataImage::~DataImage() { int DataImage::set_pixel(int x, int y, char r, char g, char b) { + if (x < 0 || x >= w() || y < 0 || y >= h()) { + return 1; + } + + long index = (y * w() * d + (x * d)); // X/Y -> buf index + *(data+index+0) = r; + *(data+index+1) = g; + *(data+index+2) = b; + + return 0; +} + + +void +DataImage::draw() { + fl_draw_image(data, 0, 0, w(), h(), d); } -static int -DataImage::get_pixel(Fl_RGB_Image *img, int x, int y, +int +DataImage::get_pixel(Fl_Image *img, int x, int y, char *r, char *g, char *b) { if ( img->d() == 0 ) { return 1; diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H index 1aebbea..563cd66 100644 --- a/src/GipfelWidget.H +++ b/src/GipfelWidget.H @@ -118,6 +118,9 @@ class GipfelWidget : public Fl_Widget { int update(); + int get_pixel(double a_view, double a_nick, + char *r, char *g, char *b); + void draw(); }; #endif diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index 0c4ef08..c6a5990 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -40,6 +40,7 @@ #include #include "Fl_Search_Chooser.H" +#include "DataImage.H" #include "choose_hill.H" #include "util.h" #include "GipfelWidget.H" @@ -714,6 +715,7 @@ GipfelWidget::set_track_width(double w) { redraw(); } + int GipfelWidget::handle(int event) { int mark_x, mark_y; @@ -743,3 +745,18 @@ GipfelWidget::handle(int event) { } return 0; } + +int +GipfelWidget::get_pixel(double a_view, double a_nick, + char *r, char *g, char *b) { + int px, py; + + + if (img == NULL) { + return 1; + } + + pan->get_coordinates(a_view, a_nick, &px, &py); + return DataImage::get_pixel(img, px, py, r, g, b); +} + diff --git a/src/Panorama.H b/src/Panorama.H index 32cefa6..740f164 100644 --- a/src/Panorama.H +++ b/src/Panorama.H @@ -144,5 +144,7 @@ class Panorama { Projection::Projection_t get_projection(); void set_projection(Projection::Projection_t p); + + int get_coordinates(double a_view, double a_nick, int *x, int *y); }; #endif diff --git a/src/Panorama.cxx b/src/Panorama.cxx index c8cb1dc..55fb9b8 100644 --- a/src/Panorama.cxx +++ b/src/Panorama.cxx @@ -586,3 +586,18 @@ Panorama::get_real_distance(Hill *m) { return c; } +int +Panorama::get_coordinates(double a_view, double a_nick, int *x, int *y) { + Hill *m = new Hill(0,0); + + m->a_view = a_view; + 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 86b8f8f..8c126f7 100644 --- a/src/Stitch.H +++ b/src/Stitch.H @@ -21,6 +21,7 @@ #define STITCH_H #include "GipfelWidget.H" +#include "DataImage.H" #define MAX_PICS 256 @@ -34,9 +35,9 @@ class Stitch { ~Stitch(); - int add_image(const char *file); + int load_image(char *file); - int resample(Fl_RGB_Image *, + int resample(DataImage *img, double view_start, double view_end, double nick_start, double nick_end); }; diff --git a/src/Stitch.cxx b/src/Stitch.cxx index 0cfa4b5..ca63ed3 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -27,17 +27,39 @@ #include "Stitch.H" Stitch::Stitch() { - - + for (int i=0; iload_image(file); + break; + } + } + +} int -Stitch::resample(Fl_Stitch_Display * +Stitch::resample(DataImage *img, + double view_start, double view_end, + double nick_start, double nick_end) { + } -- cgit v1.2.3 From b8a44e5e78d6b9f9c045f1c4e9600e1b346e099c Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sun, 25 Jun 2006 12:47:03 +0200 Subject: do not use empty string for dummy Hill name (dumps in destructor) --- src/Hill.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Hill.cxx b/src/Hill.cxx index 626e470..67e1d8e 100644 --- a/src/Hill.cxx +++ b/src/Hill.cxx @@ -58,7 +58,7 @@ Hill::Hill(const Hill& h) { } Hill::Hill(int x_tmp, int y_tmp) { - name = ""; + name = NULL; phi = 0.0; lam = 0.0; height = 0.0; -- cgit v1.2.3 From bf376cf0a996b08c39f22d46ba68be4e7957777f Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sun, 25 Jun 2006 13:02:31 +0200 Subject: first working version --- src/DataImage.cxx | 1 + src/GipfelWidget.cxx | 4 +++- src/Panorama.cxx | 25 +++++++++++++++++++------ src/Stitch.H | 3 +-- src/Stitch.cxx | 22 ++++++++++++++++++++-- src/gipfel.cxx | 31 ++++++++++++++++++++++++++++++- 6 files changed, 74 insertions(+), 12 deletions(-) (limited to 'src') 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; xw(); x++) { + for (int y=0; yh(); y++) { + double a_view, a_nick; + a_view = x * step_view; + a_nick = (y_off - y) * step_view; + + for (int i=0; iget_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); +} -- cgit v1.2.3 From 88555db930fc170f97ebbca6c17802392a5b5f25 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sun, 25 Jun 2006 13:51:38 +0200 Subject: show stitching online --- src/DataImage.cxx | 6 +++++- src/Panorama.cxx | 6 +++--- src/Stitch.cxx | 7 +++++-- src/gipfel.cxx | 9 ++++++--- 4 files changed, 19 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/DataImage.cxx b/src/DataImage.cxx index f7109cd..680d218 100644 --- a/src/DataImage.cxx +++ b/src/DataImage.cxx @@ -55,7 +55,11 @@ DataImage::set_pixel(int x, int y, char r, char g, char b) { void DataImage::draw() { - fl_draw_image(data, 0, 0, w(), h(), d); + fl_push_clip(x(), y(), w(), h()); + + fl_draw_image(data, x(), y(), w(), h(), d); + + fl_pop_clip(); } int diff --git a/src/Panorama.cxx b/src/Panorama.cxx index b33a260..a644732 100644 --- a/src/Panorama.cxx +++ b/src/Panorama.cxx @@ -593,17 +593,17 @@ Panorama::get_coordinates(double a_view, double a_nick, int *x, int *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) { + if (m.a_view > view_angle || m.a_view < - view_angle) { return 1; } - + m.a_nick = a_nick; proj->set_coordinates(&m, &parms); diff --git a/src/Stitch.cxx b/src/Stitch.cxx index 9080259..21b0ba7 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -24,6 +24,8 @@ #include #include +#include + #include "Stitch.H" Stitch::Stitch() { @@ -66,8 +68,7 @@ Stitch::resample(DataImage *img, for (int x=0; xw(); x++) { for (int y=0; yh(); y++) { double a_view, a_nick; - - a_view = x * step_view; + a_view = view_start + x * step_view; a_nick = (y_off - y) * step_view; for (int i=0; iredraw(); + Fl::check(); } } diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 8247d7d..19c21cb 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -413,17 +413,20 @@ int main(int argc, char** argv) { int stitch(int argc, char **argv) { Fl_Window *win; + Fl_Scroll *scroll; Stitch *st = new Stitch(); st->load_image("test1.jpg"); st->load_image("test2.jpg"); st->load_image("test3.jpg"); + st->load_image("test4.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 = new Fl_Window(0,0, 1000, 1000); + scroll = new Fl_Scroll(0, 0, win->w(), win->h()); + DataImage *img = new DataImage(0, 0, 2000, 500); win->show(0, argv); + st->resample(img, 0.0, 6.3); Fl::run(); exit(0); } -- cgit v1.2.3 From 5e188fda3b5d539b299a7c7ce63f98264fa8c229 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sun, 25 Jun 2006 19:31:08 +0200 Subject: adjust parameters --- src/Stitch.cxx | 21 ++++++++++++++------- src/gipfel.cxx | 20 ++++++++++++++------ 2 files changed, 28 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/Stitch.cxx b/src/Stitch.cxx index 21b0ba7..ae3158d 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -50,7 +50,10 @@ Stitch::load_image(char *file) { for (int i=0; iload_image(file); + if (gipf[i]->load_image(file) != 0) { + delete gipf[i]; + gipf[i] = NULL; + } break; } } @@ -65,11 +68,12 @@ Stitch::resample(DataImage *img, char r, g, b; int y_off = img->h() / 2; - for (int x=0; xw(); x++) { - for (int y=0; yh(); y++) { - double a_view, a_nick; + for (int y=0; yh(); y++) { + double a_nick = atan(((double)(y_off - y)/(double)img->h())); + + for (int x=0; xw(); x++) { + double a_view; a_view = view_start + x * step_view; - a_nick = (y_off - y) * step_view; for (int i=0; iredraw(); - Fl::check(); + + if (y % (img->h() / 200) == 0) { + img->redraw(); + Fl::check(); + } } } diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 19c21cb..d2850d7 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -362,6 +362,10 @@ int main(int argc, char** argv) { exit(1); } + if (stitch_flag) { + stitch(my_argc, my_argv); + } + Fl::get_system_colors(); if (getenv("FLTK_SCHEME")) { Fl::scheme(NULL); @@ -369,10 +373,6 @@ 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); @@ -420,13 +420,21 @@ int stitch(int argc, char **argv) { st->load_image("test2.jpg"); st->load_image("test3.jpg"); st->load_image("test4.jpg"); + st->load_image("test5.jpg"); + st->load_image("test6.jpg"); + st->load_image("test7.jpg"); + st->load_image("test8.jpg"); + st->load_image("test9.jpg"); + st->load_image("test10.jpg"); + st->load_image("test11.jpg"); win = new Fl_Window(0,0, 1000, 1000); scroll = new Fl_Scroll(0, 0, win->w(), win->h()); - DataImage *img = new DataImage(0, 0, 2000, 500); + DataImage *img = new DataImage(0, 0, 10000, 2000); + win->resizable(scroll); win->show(0, argv); - st->resample(img, 0.0, 6.3); + st->resample(img, 0.0, 7.0); Fl::run(); exit(0); } -- cgit v1.2.3 From 98c1c1890e91962876e53c026f5f3c502562d8b0 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sun, 25 Jun 2006 23:59:12 +0200 Subject: correct height width ratio --- src/Stitch.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Stitch.cxx b/src/Stitch.cxx index ae3158d..6bd29d2 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -28,6 +28,8 @@ #include "Stitch.H" +static double pi_d = asin(1.0) * 2.0; + Stitch::Stitch() { for (int i=0; iw(); char r, g, b; int y_off = img->h() / 2; + double radius = (double) img->w() / (view_end -view_start); for (int y=0; yh(); y++) { - double a_nick = atan(((double)(y_off - y)/(double)img->h())); + double a_nick = atan((double)(y_off - y)/radius); for (int x=0; xw(); x++) { double a_view; -- cgit v1.2.3 From 76daa38e38aff35613dcaf18330192833fd83deb Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 26 Jun 2006 17:24:20 +0200 Subject: add -w and -h switch --- src/gipfel.cxx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/gipfel.cxx b/src/gipfel.cxx index d2850d7..3a68ec3 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -62,7 +62,7 @@ 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); +int stitch(int stitch_w, int stitch_h, int argc, char **argv); void set_values() { s_center->value(gipf->get_center_angle()); @@ -323,13 +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; + int stitch_flag = 0, stitch_w = 2000, stitch_h = 500; Fl_Window *control_win, *view_win; Fl_Scroll *scroll; err = 0; - while ((c = getopt(argc, argv, "d:v:s")) != EOF) { + while ((c = getopt(argc, argv, "d:v:sw:b:")) != EOF) { switch (c) { case 'h': usage(); @@ -344,6 +344,12 @@ int main(int argc, char** argv) { case 's': stitch_flag++; break; + case 'w': + stitch_w = atoi(optarg); + break; + case 'b': + stitch_h = atoi(optarg); + break; default: err++; } @@ -363,7 +369,7 @@ int main(int argc, char** argv) { } if (stitch_flag) { - stitch(my_argc, my_argv); + stitch(stitch_w, stitch_h, my_argc, my_argv); } Fl::get_system_colors(); @@ -411,7 +417,7 @@ int main(int argc, char** argv) { return Fl::run(); } -int stitch(int argc, char **argv) { +int stitch(int stitch_w, int stitch_h, int argc, char **argv) { Fl_Window *win; Fl_Scroll *scroll; Stitch *st = new Stitch(); @@ -428,9 +434,9 @@ int stitch(int argc, char **argv) { st->load_image("test10.jpg"); st->load_image("test11.jpg"); - win = new Fl_Window(0,0, 1000, 1000); + win = new Fl_Window(0,0, 1000, stitch_h); scroll = new Fl_Scroll(0, 0, win->w(), win->h()); - DataImage *img = new DataImage(0, 0, 10000, 2000); + DataImage *img = new DataImage(0, 0, stitch_w, stitch_h); win->resizable(scroll); win->show(0, argv); -- cgit v1.2.3 From 70a6e7c52eb8830e7e2c5884247201defdeb6a1c Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 26 Jun 2006 18:05:47 +0200 Subject: switch to double coordinates --- src/DataImage.H | 6 ++++++ src/DataImage.cxx | 19 ++++++++++++++++++- src/GipfelWidget.cxx | 9 ++++++--- src/Panorama.H | 2 +- src/Panorama.cxx | 30 ++++++++++++------------------ src/Projection.H | 3 ++- src/Projection.cxx | 3 ++- src/ProjectionSphaeric.H | 5 ++--- src/ProjectionSphaeric.cxx | 22 ++++++---------------- src/ProjectionTangential.H | 3 ++- src/ProjectionTangential.cxx | 11 ++++++----- 11 files changed, 63 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/DataImage.H b/src/DataImage.H index fe6200d..ec3b1ec 100644 --- a/src/DataImage.H +++ b/src/DataImage.H @@ -40,6 +40,12 @@ class DataImage : public Fl_Widget { static int get_pixel(Fl_Image *img, int x, int y, char *r, char *g, char *b); + + static int get_pixel_bilinear(Fl_Image *img, double x, double y, + char *r, char *g, char *b); + + static int get_pixel_nearest(Fl_Image *img, double x, double y, + char *r, char *g, char *b); }; #endif diff --git a/src/DataImage.cxx b/src/DataImage.cxx index 680d218..efc05e3 100644 --- a/src/DataImage.cxx +++ b/src/DataImage.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -62,6 +63,23 @@ DataImage::draw() { fl_pop_clip(); } +int +DataImage::get_pixel_bilinear(Fl_Image *img, double x, double y, + char *r, char *g, char *b) { + + +} + +int +DataImage::get_pixel_nearest(Fl_Image *img, double x, double y, + char *r, char *g, char *b) { + if (isnan(x) || isnan(y)) { + return 1; + } else { + return get_pixel(img, (int) rint(x), (int) rint(y), r, g, b); + } +} + int DataImage::get_pixel(Fl_Image *img, int x, int y, char *r, char *g, char *b) { @@ -72,7 +90,6 @@ DataImage::get_pixel(Fl_Image *img, int x, int y, if (x < 0 || x >=img->w() || y < 0 || y >= img->h()) { return 1; } - long index = (y * img->w() * img->d()) + (x * img->d()); // X/Y -> buf index switch ( img->count() ) { case 1: { // bitmap diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index aac0b49..67695ad 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -749,16 +749,19 @@ GipfelWidget::handle(int event) { int GipfelWidget::get_pixel(double a_view, double a_nick, char *r, char *g, char *b) { - int px, py; + double px, py; if (img == NULL) { return 1; } - pan->get_coordinates(a_view, a_nick, &px, &py); + if (pan->get_coordinates(a_view, a_nick, &px, &py) != 0) { + return 1; + } //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); + return DataImage::get_pixel_nearest(img, px + ((double) img->w()) / 2.0, + py + ((double) img->h()) / 2.0, r, g, b); } diff --git a/src/Panorama.H b/src/Panorama.H index 740f164..20d3213 100644 --- a/src/Panorama.H +++ b/src/Panorama.H @@ -145,6 +145,6 @@ class Panorama { void set_projection(Projection::Projection_t p); - int get_coordinates(double a_view, double a_nick, int *x, int *y); + int get_coordinates(double a_view, double a_nick, double *x, double *y); }; #endif diff --git a/src/Panorama.cxx b/src/Panorama.cxx index a644732..73bc003 100644 --- a/src/Panorama.cxx +++ b/src/Panorama.cxx @@ -508,8 +508,11 @@ Panorama::update_coordinates() { for (int i=0; iget_num(); i++) { m = visible_mountains->get(i); + double tmp_x, tmp_y; - proj->set_coordinates(m, &parms); + proj->get_coordinates(m->a_view, m->a_nick, &parms, &tmp_x, &tmp_y); + m->x = (int) rint(tmp_x); + m->y = (int) rint(tmp_y); } } @@ -587,29 +590,20 @@ Panorama::get_real_distance(Hill *m) { } int -Panorama::get_coordinates(double a_view, double a_nick, int *x, int *y) { - Hill m(0,0); +Panorama::get_coordinates(double a_view, double a_nick, double *x, double *y) { + a_view = a_view - parms.a_center; - - - 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 (a_view > pi_d) { + a_view -= 2.0*pi_d; + } else if (a_view < -pi_d) { + a_view += 2.0*pi_d; } - if (m.a_view > view_angle || m.a_view < - view_angle) { + if (a_view > view_angle || a_view < - view_angle) { return 1; } - m.a_nick = a_nick; - - proj->set_coordinates(&m, &parms); - - *x = m.x; - *y = m.y; + proj->get_coordinates(a_view, a_nick, &parms, x, y); return 0; } diff --git a/src/Projection.H b/src/Projection.H index b81e531..f6de5ae 100644 --- a/src/Projection.H +++ b/src/Projection.H @@ -37,7 +37,8 @@ class Projection { Projection(); - virtual void set_coordinates(Hill *m, const ViewParams *parms); + virtual void get_coordinates(double a_view, double a_nick, + const ViewParams *parms, double *x, double *y); virtual int comp_params(const Hill *m1, const Hill *m2, ViewParams *parms); }; diff --git a/src/Projection.cxx b/src/Projection.cxx index 57a210a..1f224e8 100644 --- a/src/Projection.cxx +++ b/src/Projection.cxx @@ -31,7 +31,8 @@ Projection::Projection() { }; void -Projection::set_coordinates(Hill *m, const ViewParams *parms) { +Projection::get_coordinates(double a_view, double a_nick, + const ViewParams *parms, double *x, double *y) { fprintf(stderr, "Error: Projection::set_coordinates()\n"); } diff --git a/src/ProjectionSphaeric.H b/src/ProjectionSphaeric.H index fcaffa8..06396f1 100644 --- a/src/ProjectionSphaeric.H +++ b/src/ProjectionSphaeric.H @@ -30,11 +30,10 @@ class ProjectionSphaeric : public Projection { double comp_dir_view(const Hill *m1, const Hill *m2, double d_m1_2, double d_m2_2, double scale, double sign3); double comp_nick_view(const Hill *m1, const Hill *m2, double d_m1_2, double scale, double dir_view, double sign1); double comp_tilt_view(const Hill *m, double scale, double dir_view, double nick_view); - void set_coordinates(const Hill *m, const ViewParams *parms, - double *x, double *y); public: - void set_coordinates(Hill *m, const ViewParams *parms); + void get_coordinates(double a_view, double a_nick, const ViewParams *parms, + double *x, double *y); int comp_params(const Hill *m1, const Hill *m2, ViewParams *parms); }; diff --git a/src/ProjectionSphaeric.cxx b/src/ProjectionSphaeric.cxx index 74c9de6..e69882b 100644 --- a/src/ProjectionSphaeric.cxx +++ b/src/ProjectionSphaeric.cxx @@ -66,9 +66,9 @@ ProjectionSphaeric::comp_params(const Hill *m1, const Hill *m2, ViewParams *parm isnan(tmp.a_nick) || isnan(tmp.a_tilt)) { ; } else { - set_coordinates(m1, &tmp, &tmp_x, &tmp_y); + get_coordinates(m1->a_view, m1->a_nick, &tmp, &tmp_x, &tmp_y); val = sqrt(pow(tmp_x - m1->x, 2.0) + pow(tmp_y - m1->y, 2.0)); - set_coordinates(m2, &tmp, &tmp_x, &tmp_y); + get_coordinates(m2->a_view, m2->a_nick, &tmp, &tmp_x, &tmp_y); val += sqrt(pow(tmp_x - m2->x, 2.0) + pow(tmp_y - m2->y, 2.0)); if (val < best_val) { @@ -88,22 +88,12 @@ ProjectionSphaeric::comp_params(const Hill *m1, const Hill *m2, ViewParams *parm } void -ProjectionSphaeric::set_coordinates(Hill *m, const ViewParams *parms) { +ProjectionSphaeric::get_coordinates(double a_view, double a_nick, + const ViewParams *parms, double *x, double *y) { double x_tmp, y_tmp; - set_coordinates(m, parms, &x_tmp, &y_tmp); - - m->x = (int) rint(x_tmp); - m->y = (int) rint(y_tmp); -} - -void -ProjectionSphaeric::set_coordinates(const Hill *m, const ViewParams *parms, - double *x, double *y) { - double x_tmp, y_tmp; - - x_tmp = m->a_view * parms->scale; - y_tmp = - (m->a_nick - parms->a_nick) * parms->scale; + x_tmp = a_view * parms->scale; + y_tmp = - (a_nick - parms->a_nick) * parms->scale; // rotate by a_tilt; *x = x_tmp * cos(parms->a_tilt) - y_tmp * sin(parms->a_tilt); diff --git a/src/ProjectionTangential.H b/src/ProjectionTangential.H index 8e7673e..74a4b59 100644 --- a/src/ProjectionTangential.H +++ b/src/ProjectionTangential.H @@ -36,7 +36,8 @@ class ProjectionTangential : public Projection { int optimize(const Hill *m1, const Hill *m2, ViewParams *parms); public: - void set_coordinates(Hill *m, const ViewParams *parms); + void get_coordinates(double a_view, double a_nick, const ViewParams *parms, + double *x, double *y); int comp_params(const Hill *m1, const Hill *m2, ViewParams *parms); }; diff --git a/src/ProjectionTangential.cxx b/src/ProjectionTangential.cxx index 032005d..416d27d 100644 --- a/src/ProjectionTangential.cxx +++ b/src/ProjectionTangential.cxx @@ -160,15 +160,16 @@ ProjectionTangential::optimize(const Hill *m1, const Hill *m2, ViewParams *parms } void -ProjectionTangential::set_coordinates(Hill *m, const ViewParams *parms) { +ProjectionTangential::get_coordinates(double a_view, double a_nick, + const ViewParams *parms, double *x, double *y) { double x_tmp, y_tmp; - x_tmp = tan(m->a_view) * parms->scale; - y_tmp = - (tan(m->a_nick - parms->a_nick) * parms->scale); + x_tmp = tan(a_view) * parms->scale; + y_tmp = - (tan(a_nick - parms->a_nick) * parms->scale); // rotate by a_tilt; - m->x = (int) rint(x_tmp * cos(parms->a_tilt) - y_tmp * sin(parms->a_tilt)); - m->y = (int) rint(x_tmp * sin(parms->a_tilt) + y_tmp * cos(parms->a_tilt)); + *x = x_tmp * cos(parms->a_tilt) - y_tmp * sin(parms->a_tilt); + *y = x_tmp * sin(parms->a_tilt) + y_tmp * cos(parms->a_tilt); } double -- cgit v1.2.3 From fe07ad525e8326bf857d5ac8e1998ff3b7c343d1 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Thu, 29 Jun 2006 21:16:14 +0200 Subject: use image files from command line for stitching --- src/gipfel.cxx | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 3a68ec3..a5b0fc9 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -422,17 +422,9 @@ int stitch(int stitch_w, int stitch_h, int argc, char **argv) { Fl_Scroll *scroll; Stitch *st = new Stitch(); - st->load_image("test1.jpg"); - st->load_image("test2.jpg"); - st->load_image("test3.jpg"); - st->load_image("test4.jpg"); - st->load_image("test5.jpg"); - st->load_image("test6.jpg"); - st->load_image("test7.jpg"); - st->load_image("test8.jpg"); - st->load_image("test9.jpg"); - st->load_image("test10.jpg"); - st->load_image("test11.jpg"); + for (int i=0; iload_image(argv[i]); + } win = new Fl_Window(0,0, 1000, stitch_h); scroll = new Fl_Scroll(0, 0, win->w(), win->h()); -- cgit v1.2.3 From 3ad29069b15a21d1b9f3d965d70cecce8c650c4c Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Thu, 29 Jun 2006 21:19:03 +0200 Subject: fix core with small image heights --- src/Stitch.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Stitch.cxx b/src/Stitch.cxx index 6bd29d2..535995f 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -88,7 +88,7 @@ Stitch::resample(DataImage *img, } } - if (y % (img->h() / 200) == 0) { + if (y % (img->h() / 100 + 1) == 0) { img->redraw(); Fl::check(); } -- cgit v1.2.3 From d258151391bead3a167f54068096a8d727ba273a Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 31 Jul 2006 17:09:25 +0200 Subject: add jpeg write support to DataImage --- src/DataImage.H | 2 ++ src/DataImage.cxx | 41 +++++++++++++++++++++++++++++++++++++++-- src/gipfel.cxx | 2 ++ 3 files changed, 43 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/DataImage.H b/src/DataImage.H index ec3b1ec..49cd952 100644 --- a/src/DataImage.H +++ b/src/DataImage.H @@ -38,6 +38,8 @@ class DataImage : public Fl_Widget { void draw(); + int write_jpeg(const char *file, int quality); + static int get_pixel(Fl_Image *img, int x, int y, char *r, char *g, char *b); diff --git a/src/DataImage.cxx b/src/DataImage.cxx index efc05e3..f7968b2 100644 --- a/src/DataImage.cxx +++ b/src/DataImage.cxx @@ -23,6 +23,9 @@ #include #include #include +extern "C" { +#include +} #include @@ -31,7 +34,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); + memset(data, 200, W * H * d); } DataImage::~DataImage() { @@ -117,10 +120,44 @@ DataImage::get_pixel(Fl_Image *img, int x, int y, return 0; } - +int +DataImage::write_jpeg(const char *file, int quality) { + struct jpeg_compress_struct cinfo; + struct jpeg_error_mgr jerr; + FILE *outfile; + JSAMPROW row_pointer[1]; + int row_stride; + + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_compress(&cinfo); + + if ((outfile = fopen(file, "wb")) == NULL) { + fprintf(stderr, "can't open %s\n", file); + return 1; + } + jpeg_stdio_dest(&cinfo, outfile); + cinfo.image_width = w(); + cinfo.image_height = h(); + cinfo.input_components = 3; /* # of color components per pixel */ + cinfo.in_color_space = JCS_RGB; + jpeg_set_defaults(&cinfo); + jpeg_set_quality(&cinfo, quality, TRUE); + jpeg_start_compress(&cinfo, TRUE); + row_stride = w() * 3; /* JSAMPLEs per row in image_buffer */ + while (cinfo.next_scanline < cinfo.image_height) { + row_pointer[0] = & data[cinfo.next_scanline * row_stride]; + jpeg_write_scanlines(&cinfo, row_pointer, 1); + } + + jpeg_finish_compress(&cinfo); + fclose(outfile); + jpeg_destroy_compress(&cinfo); + + return 0; +} diff --git a/src/gipfel.cxx b/src/gipfel.cxx index a5b0fc9..acdd1de 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -433,6 +433,8 @@ int stitch(int stitch_w, int stitch_h, int argc, char **argv) { win->show(0, argv); st->resample(img, 0.0, 7.0); + + img->write_jpeg("/tmp/bla.jpg", 90); Fl::run(); exit(0); } -- cgit v1.2.3 From ff7773a8da615e4dc91320636beb4e6877777a01 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 31 Jul 2006 20:34:14 +0200 Subject: initial tiff write support --- src/DataImage.H | 2 ++ src/DataImage.cxx | 32 ++++++++++++++++++++++++++++++++ src/gipfel.cxx | 1 + 3 files changed, 35 insertions(+) (limited to 'src') diff --git a/src/DataImage.H b/src/DataImage.H index 49cd952..a8fb100 100644 --- a/src/DataImage.H +++ b/src/DataImage.H @@ -40,6 +40,8 @@ class DataImage : public Fl_Widget { int write_jpeg(const char *file, int quality); + int write_tiff(const char *file); + static int get_pixel(Fl_Image *img, int x, int y, char *r, char *g, char *b); diff --git a/src/DataImage.cxx b/src/DataImage.cxx index f7968b2..2f1ad80 100644 --- a/src/DataImage.cxx +++ b/src/DataImage.cxx @@ -25,6 +25,7 @@ #include extern "C" { #include +#include } #include @@ -161,3 +162,34 @@ DataImage::write_jpeg(const char *file, int quality) { return 0; } + +int +DataImage::write_tiff(const char *file) { + TIFF *output; + uint32 width, height; + char *raster; + + // Open the output image + if((output = TIFFOpen(file, "w")) == NULL){ + fprintf(stderr, "can't open %s\n", file); + return 1; + } + + // Write the tiff tags to the file + TIFFSetField(output, TIFFTAG_IMAGEWIDTH, w()); + TIFFSetField(output, TIFFTAG_IMAGELENGTH, h()); + TIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE); + TIFFSetField(output, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField(output, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); + TIFFSetField(output, TIFFTAG_BITSPERSAMPLE, 8); + TIFFSetField(output, TIFFTAG_SAMPLESPERPIXEL, 3); + + // Actually write the image + if(TIFFWriteEncodedStrip(output, 0, data, w() * h() * 3) == 0){ + fprintf(stderr, "Could not write image\n"); + return 2; + } + + TIFFClose(output); + return 0; +} diff --git a/src/gipfel.cxx b/src/gipfel.cxx index acdd1de..309ee9d 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -435,6 +435,7 @@ int stitch(int stitch_w, int stitch_h, int argc, char **argv) { st->resample(img, 0.0, 7.0); img->write_jpeg("/tmp/bla.jpg", 90); + img->write_tiff("/tmp/bla.tiff"); Fl::run(); exit(0); } -- cgit v1.2.3 From a00d85aef36050ffd29b46ed19e04a5af9a47488 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 31 Jul 2006 21:11:27 +0200 Subject: add tiff stitching --- src/DataImage.H | 2 +- src/DataImage.cxx | 15 +++++++++------ src/gipfel.cxx | 44 +++++++++++++++++++++++++++++++++++++------- 3 files changed, 47 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/DataImage.H b/src/DataImage.H index a8fb100..1846857 100644 --- a/src/DataImage.H +++ b/src/DataImage.H @@ -30,7 +30,7 @@ class DataImage : public Fl_Widget { public: - DataImage(int X, int Y, int W, int H); + DataImage(int X, int Y, int W, int H, int channels=3); ~DataImage(); diff --git a/src/DataImage.cxx b/src/DataImage.cxx index 2f1ad80..21aa226 100644 --- a/src/DataImage.cxx +++ b/src/DataImage.cxx @@ -32,10 +32,10 @@ extern "C" { #include "DataImage.H" -DataImage::DataImage(int X, int Y, int W, int H): Fl_Widget(X, Y, W, H) { - d = 3; +DataImage::DataImage(int X, int Y, int W, int H, int channels): Fl_Widget(X, Y, W, H) { + d = channels; data = (uchar*) malloc(W * H * d); - memset(data, 200, W * H * d); + memset(data, 0, W * H * d); } DataImage::~DataImage() { @@ -53,6 +53,9 @@ DataImage::set_pixel(int x, int y, char r, char g, char b) { *(data+index+0) = r; *(data+index+1) = g; *(data+index+2) = b; + if (d == 4) { + *(data+index+3) = 255; + } return 0; } @@ -150,7 +153,7 @@ DataImage::write_jpeg(const char *file, int quality) { jpeg_start_compress(&cinfo, TRUE); - row_stride = w() * 3; /* JSAMPLEs per row in image_buffer */ + row_stride = w() * d; /* JSAMPLEs per row in image_buffer */ while (cinfo.next_scanline < cinfo.image_height) { row_pointer[0] = & data[cinfo.next_scanline * row_stride]; jpeg_write_scanlines(&cinfo, row_pointer, 1); @@ -182,10 +185,10 @@ DataImage::write_tiff(const char *file) { TIFFSetField(output, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(output, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); TIFFSetField(output, TIFFTAG_BITSPERSAMPLE, 8); - TIFFSetField(output, TIFFTAG_SAMPLESPERPIXEL, 3); + TIFFSetField(output, TIFFTAG_SAMPLESPERPIXEL, d); // Actually write the image - if(TIFFWriteEncodedStrip(output, 0, data, w() * h() * 3) == 0){ + if(TIFFWriteEncodedStrip(output, 0, data, w() * h() * d) == 0){ fprintf(stderr, "Could not write image\n"); return 2; } diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 309ee9d..d8cea1c 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -62,7 +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 stitch_w, int stitch_h, int argc, char **argv); +static int tiffstitch(int stitch_w, int stitch_h, int argc, char **argv); +static int stitch(int stitch_w, int stitch_h, int argc, char **argv); void set_values() { s_center->value(gipf->get_center_angle()); @@ -323,13 +324,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, stitch_w = 2000, stitch_h = 500; + int stitch_flag = 0, tiff_flag = 0, stitch_w = 2000, stitch_h = 500; Fl_Window *control_win, *view_win; Fl_Scroll *scroll; err = 0; - while ((c = getopt(argc, argv, "d:v:sw:b:")) != EOF) { + while ((c = getopt(argc, argv, "d:v:sw:b:t")) != EOF) { switch (c) { case 'h': usage(); @@ -344,6 +345,10 @@ int main(int argc, char** argv) { case 's': stitch_flag++; break; + case 't': + stitch_flag++; + tiff_flag++; + break; case 'w': stitch_w = atoi(optarg); break; @@ -369,7 +374,12 @@ int main(int argc, char** argv) { } if (stitch_flag) { - stitch(stitch_w, stitch_h, my_argc, my_argv); + if (tiff_flag) { + tiffstitch(stitch_w, stitch_h, my_argc, my_argv); + } else { + stitch(stitch_w, stitch_h, my_argc, my_argv); + } + exit(0); } Fl::get_system_colors(); @@ -417,7 +427,27 @@ int main(int argc, char** argv) { return Fl::run(); } -int stitch(int stitch_w, int stitch_h, int argc, char **argv) { +static int tiffstitch(int stitch_w, int stitch_h, int argc, char **argv) { + char buf[256]; + + for (int i=0; iload_image(argv[i]); + + st->resample(img, 0.0, 7.0); + snprintf(buf, sizeof(buf), "gipfel_%d.tiff", i); + img->write_tiff(buf); + delete st; + delete img; + } + + return 0; +} + + +static int stitch(int stitch_w, int stitch_h, int argc, char **argv) { Fl_Window *win; Fl_Scroll *scroll; Stitch *st = new Stitch(); @@ -435,7 +465,7 @@ int stitch(int stitch_w, int stitch_h, int argc, char **argv) { st->resample(img, 0.0, 7.0); img->write_jpeg("/tmp/bla.jpg", 90); - img->write_tiff("/tmp/bla.tiff"); Fl::run(); - exit(0); + + return 0; } -- cgit v1.2.3 From 2a7604a5f909115a5fd633f4a058b1890b13d7ef Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 1 Aug 2006 16:03:46 +0200 Subject: add OutputImage stuff --- src/JPEGOutputImage.H | 38 +++++++++++++++++++++++++++++++++ src/OutputImage.H | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 src/JPEGOutputImage.H create mode 100644 src/OutputImage.H (limited to 'src') diff --git a/src/JPEGOutputImage.H b/src/JPEGOutputImage.H new file mode 100644 index 0000000..2a56bca --- /dev/null +++ b/src/JPEGOutputImage.H @@ -0,0 +1,38 @@ +// +// Copyright 2006 by Johannes Hofmann +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// + +#ifndef JPEGOUTPUTIMAGE_H +#define JPEGOUTPUTIMAGE_H + + +class JPEGOutputImage : OutputImage { + public: + JPEGOutputImage(); + + ~JPEGOutputImage(); + + int init(int w, int h); + + protected: + int set_pixel_internal(int x, char r, char g, char b); + + int next_line_internal(); +}; + +#endif diff --git a/src/OutputImage.H b/src/OutputImage.H new file mode 100644 index 0000000..4ecb0e4 --- /dev/null +++ b/src/OutputImage.H @@ -0,0 +1,59 @@ +// +// Copyright 2006 by Johannes Hofmann +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// + +#ifndef OUTPUTIMAGE_H +#define OUTPUTIMAGE_H + + +class OutputImage { + public: + OutputImage(); + + ~OutputImage(); + + virtual int init(int w, int h); + + int set_pixel(int x, char r, char g, char b); + + int next_line(); + + protected: + virtual int set_pixel_internal(int x, char r, char g, char b); + + virtual int next_line_internal(); +}; + +class OutputImages { + public: + OutputImages(); + + ~OutputImages(); + + int add(OutputImage *i); + + int remove(OutputImage *i); + + int init(int w, int h); + + int set_pixel(int x, char r, char g, char b); + + int next_line(); +} + +#endif -- cgit v1.2.3 From 97f03d296d77284c723d9ff8485fed51dc17c32c Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 1 Aug 2006 16:30:44 +0200 Subject: implement OutputImage stuff --- src/JPEGOutputImage.H | 2 ++ src/OutputImage.H | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/JPEGOutputImage.H b/src/JPEGOutputImage.H index 2a56bca..23ca25c 100644 --- a/src/JPEGOutputImage.H +++ b/src/JPEGOutputImage.H @@ -29,6 +29,8 @@ class JPEGOutputImage : OutputImage { int init(int w, int h); + int done(); + protected: int set_pixel_internal(int x, char r, char g, char b); diff --git a/src/OutputImage.H b/src/OutputImage.H index 4ecb0e4..65aca92 100644 --- a/src/OutputImage.H +++ b/src/OutputImage.H @@ -22,21 +22,30 @@ class OutputImage { + private: + int w, h; + public: OutputImage(); ~OutputImage(); - virtual int init(int w, int h); + virtual int init(int w1, int h1); int set_pixel(int x, char r, char g, char b); int next_line(); + int done(); + protected: + virtual int init_internal(int w1, h1); + virtual int set_pixel_internal(int x, char r, char g, char b); virtual int next_line_internal(); + + virtual int done_internal(); }; class OutputImages { @@ -54,6 +63,8 @@ class OutputImages { int set_pixel(int x, char r, char g, char b); int next_line(); + + int done(); } #endif -- cgit v1.2.3 From d40e2b31d77face2fb65c41cc4d901f01c5de5d1 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 1 Aug 2006 22:40:33 +0200 Subject: implement JPEGOutputImage --- src/JPEGOutputImage.H | 25 ++++++++++++++++++++----- src/Makefile.am | 6 ++++-- src/OutputImage.H | 14 +++++++++----- 3 files changed, 33 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/JPEGOutputImage.H b/src/JPEGOutputImage.H index 23ca25c..bf1c6c1 100644 --- a/src/JPEGOutputImage.H +++ b/src/JPEGOutputImage.H @@ -20,21 +20,36 @@ #ifndef JPEGOUTPUTIMAGE_H #define JPEGOUTPUTIMAGE_H +#include +extern "C" { +#include +} + +#include "OutputImage.H" class JPEGOutputImage : OutputImage { + private: + unsigned char *row; + char *file; + int w, h; + struct jpeg_compress_struct cinfo; + struct jpeg_error_mgr jerr; + FILE *fp; + int quality; + public: - JPEGOutputImage(); + JPEGOutputImage(const char *file, int quality = 90); ~JPEGOutputImage(); - - int init(int w, int h); - - int done(); protected: + int init_internal(int w, int h); + int set_pixel_internal(int x, char r, char g, char b); int next_line_internal(); + + int done_internal(); }; #endif diff --git a/src/Makefile.am b/src/Makefile.am index e8b384a..466b772 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,7 +13,8 @@ gipfel_SOURCES = \ Fl_Search_Chooser.cxx \ choose_hill.cxx \ Stitch.cxx \ - DataImage.cxx + OutputImage.cxx \ + JPEGOutputImage.cxx noinst_HEADERS = \ GipfelWidget.H \ @@ -27,5 +28,6 @@ noinst_HEADERS = \ Fl_Search_Chooser.H \ choose_hill.H \ Stitch.H \ - DataImage.H \ + OutputImage.H \ + JPEGOutputImage.H \ util.h diff --git a/src/OutputImage.H b/src/OutputImage.H index 65aca92..9a99548 100644 --- a/src/OutputImage.H +++ b/src/OutputImage.H @@ -23,7 +23,7 @@ class OutputImage { private: - int w, h; + int w, h, initialized, line; public: OutputImage(); @@ -39,7 +39,7 @@ class OutputImage { int done(); protected: - virtual int init_internal(int w1, h1); + virtual int init_internal(int w1, int h1); virtual int set_pixel_internal(int x, char r, char g, char b); @@ -49,14 +49,18 @@ class OutputImage { }; class OutputImages { + private: + OutputImage **imgs; + int max_imgs; + public: OutputImages(); ~OutputImages(); - int add(OutputImage *i); + int add(OutputImage *img); - int remove(OutputImage *i); + int remove(OutputImage *img); int init(int w, int h); @@ -65,6 +69,6 @@ class OutputImages { int next_line(); int done(); -} +}; #endif -- cgit v1.2.3 From 52669d81a766eacc1b4e60d0cf477e35b598fcbe Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Wed, 2 Aug 2006 17:12:55 +0200 Subject: change Stitch to use OutputImage instead of DataImage --- src/GipfelWidget.H | 5 ++++ src/GipfelWidget.cxx | 52 +++++++++++++++++++++++++++++++-- src/JPEGOutputImage.H | 1 + src/Stitch.H | 13 +++++++-- src/Stitch.cxx | 79 +++++++++++++++++++++++++++++++++++++++++++-------- src/gipfel.cxx | 27 +++++++----------- 6 files changed, 143 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H index 563cd66..50cb10d 100644 --- a/src/GipfelWidget.H +++ b/src/GipfelWidget.H @@ -49,6 +49,9 @@ class GipfelWidget : public Fl_Widget { int get_rel_track_width(Hill *m); + static int get_pixel_nearest(Fl_Image *img, double x, double y, + char *r, char *g, char *b); + public: GipfelWidget(int X,int Y,int W, int H); @@ -57,6 +60,8 @@ class GipfelWidget : public Fl_Widget { int load_image(char *file); int save_image(char *file); + + const char * get_image_filename(); int load_data(const char *file); diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index 67695ad..34716e0 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -40,7 +40,6 @@ #include #include "Fl_Search_Chooser.H" -#include "DataImage.H" #include "choose_hill.H" #include "util.h" #include "GipfelWidget.H" @@ -148,6 +147,11 @@ GipfelWidget::load_image(char *file) { return 0; } +const char * +GipfelWidget::get_image_filename() { + return img_file; +} + int GipfelWidget::save_image(char *file) { char * args[32]; @@ -760,8 +764,50 @@ GipfelWidget::get_pixel(double a_view, double a_nick, return 1; } -//printf("===> %s: %f, %f -> %d %d\n", img_file, a_view, a_nick, px, py); - return DataImage::get_pixel_nearest(img, px + ((double) img->w()) / 2.0, + return get_pixel_nearest(img, px + ((double) img->w()) / 2.0, py + ((double) img->h()) / 2.0, r, g, b); } +int +GipfelWidget::get_pixel_nearest(Fl_Image *img, double x, double y, + char *r, char *g, char *b) { + if (isnan(x) || isnan(y)) { + return 1; + } + + if ( img->d() == 0 ) { + return 1; + } + + if (x < 0 || x >=img->w() || y < 0 || y >= img->h()) { + return 1; + } + long index = (y * img->w() * img->d()) + (x * img->d()); // X/Y -> buf index + switch ( img->count() ) { + case 1: { // bitmap + const char *buf = img->data()[0]; + switch ( img->d() ) { + case 1: { // 8bit + *r = *g = *b = *(buf+index); + break; + } + case 3: // 24bit + *r = *(buf+index+0); + *g = *(buf+index+1); + *b = *(buf+index+2); + break; + default: // ?? + printf("Not supported: chans=%d\n", img->d()); + return 1; + } + break; + } + default: // ?? pixmap, bit vals + printf("Not supported: count=%d\n", img->count()); + return 1; + } + + return 0; + +} + diff --git a/src/JPEGOutputImage.H b/src/JPEGOutputImage.H index bf1c6c1..31bdd76 100644 --- a/src/JPEGOutputImage.H +++ b/src/JPEGOutputImage.H @@ -23,6 +23,7 @@ #include extern "C" { #include +#undef HAVE_STDLIB_H } #include "OutputImage.H" diff --git a/src/Stitch.H b/src/Stitch.H index bc8436e..0bb6d48 100644 --- a/src/Stitch.H +++ b/src/Stitch.H @@ -21,13 +21,16 @@ #define STITCH_H #include "GipfelWidget.H" -#include "DataImage.H" +#include "OutputImage.H" #define MAX_PICS 256 + class Stitch { private: GipfelWidget *gipf[MAX_PICS]; + OutputImage *single_images[MAX_PICS]; + OutputImage *merged_image; public: @@ -36,8 +39,12 @@ class Stitch { ~Stitch(); int load_image(char *file); - - int resample(DataImage *img, + + OutputImage * set_output(OutputImage *img); + + OutputImage * set_output(const char *file, OutputImage *img); + + int resample(int w, int h, double view_start, double view_end); }; diff --git a/src/Stitch.cxx b/src/Stitch.cxx index 535995f..1fe3d88 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -26,6 +26,7 @@ #include +#include "OutputImage.H" #include "Stitch.H" static double pi_d = asin(1.0) * 2.0; @@ -33,7 +34,9 @@ static double pi_d = asin(1.0) * 2.0; Stitch::Stitch() { for (int i=0; iget_image_filename(); + if (img_file && strcmp(file, img_file) == 0) { + ret = single_images[i]; + single_images[i] = img; + break; + } + } + } + + return ret; +} + int -Stitch::resample(DataImage *img, +Stitch::resample(int w, int h, double view_start, double view_end) { - double step_view = (view_end - view_start) / img->w(); + double step_view = (view_end - view_start) / w; char r, g, b; - int y_off = img->h() / 2; - double radius = (double) img->w() / (view_end -view_start); + int y_off = h / 2; + int merged_pixel_set; + double radius = (double) w / (view_end -view_start); - for (int y=0; yh(); y++) { + if (merged_image) { + merged_image->init(w, h); + } + for (int i=0; iinit(w, h); + } + } + + for (int y=0; yw(); x++) { + for (int x=0; xget_pixel(a_view, a_nick, &r, &g, &b)==0) { - img->set_pixel(x, y, r, g, b); - break; + if (single_images[i]) { + single_images[i]->set_pixel(x, r, g, b); + } + if (!merged_pixel_set && merged_image) { + merged_image->set_pixel(x, r, g, b); + merged_pixel_set++; + } } } } + if (merged_image) { + merged_image->next_line(); + } + for (int i=0; inext_line(); + } + } + } - if (y % (img->h() / 100 + 1) == 0) { - img->redraw(); - Fl::check(); + if (merged_image) { + merged_image->done(); + } + for (int i=0; idone(); } } } diff --git a/src/gipfel.cxx b/src/gipfel.cxx index d8cea1c..5cd170a 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -41,7 +41,7 @@ #include "Fl_Value_Dial.H" #include "Fl_Search_Chooser.H" #include "GipfelWidget.H" -#include "DataImage.H" +#include "JPEGOutputImage.H" #include "Stitch.H" #include "choose_hill.H" #include "../config.h" @@ -62,7 +62,6 @@ Fl_Value_Input *i_view_lat, *i_view_long, *i_view_height; Fl_Box *b_viewpoint; Fl_Menu_Bar *mb; -static int tiffstitch(int stitch_w, int stitch_h, int argc, char **argv); static int stitch(int stitch_w, int stitch_h, int argc, char **argv); void set_values() { @@ -324,13 +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, tiff_flag = 0, stitch_w = 2000, stitch_h = 500; + int stitch_flag = 0, stitch_w = 2000, stitch_h = 500; Fl_Window *control_win, *view_win; Fl_Scroll *scroll; err = 0; - while ((c = getopt(argc, argv, "d:v:sw:b:t")) != EOF) { + while ((c = getopt(argc, argv, "d:v:sw:b:")) != EOF) { switch (c) { case 'h': usage(); @@ -345,10 +344,6 @@ int main(int argc, char** argv) { case 's': stitch_flag++; break; - case 't': - stitch_flag++; - tiff_flag++; - break; case 'w': stitch_w = atoi(optarg); break; @@ -374,11 +369,7 @@ int main(int argc, char** argv) { } if (stitch_flag) { - if (tiff_flag) { - tiffstitch(stitch_w, stitch_h, my_argc, my_argv); - } else { - stitch(stitch_w, stitch_h, my_argc, my_argv); - } + stitch(stitch_w, stitch_h, my_argc, my_argv); exit(0); } @@ -427,6 +418,7 @@ int main(int argc, char** argv) { return Fl::run(); } +#if 0 static int tiffstitch(int stitch_w, int stitch_h, int argc, char **argv) { char buf[256]; @@ -445,6 +437,7 @@ static int tiffstitch(int stitch_w, int stitch_h, int argc, char **argv) { return 0; } +#endif static int stitch(int stitch_w, int stitch_h, int argc, char **argv) { @@ -455,16 +448,18 @@ static int stitch(int stitch_w, int stitch_h, int argc, char **argv) { for (int i=0; iload_image(argv[i]); } - +#if 0 win = new Fl_Window(0,0, 1000, stitch_h); scroll = new Fl_Scroll(0, 0, win->w(), win->h()); - DataImage *img = new DataImage(0, 0, stitch_w, stitch_h); + PreviewOutputImage *img = new PreviewOutputImage(); win->resizable(scroll); win->show(0, argv); st->resample(img, 0.0, 7.0); +#endif - img->write_jpeg("/tmp/bla.jpg", 90); + st->set_output((OutputImage*) new JPEGOutputImage("/tmp/bla.jpg", 90)); + st->resample(stitch_w, stitch_h, 0.0, 7.0); Fl::run(); return 0; -- cgit v1.2.3 From 732e18ac89479a9a789068b32145825bb0c98ba4 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Wed, 2 Aug 2006 18:00:23 +0200 Subject: implement PreviewOutputImage --- src/DataImage.H | 55 ------------- src/DataImage.cxx | 198 --------------------------------------------- src/GipfelWidget.H | 3 + src/GipfelWidget.cxx | 15 +++- src/Makefile.am | 4 +- src/OutputImage.H | 2 +- src/PreviewOutputImage.H | 53 ++++++++++++ src/PreviewOutputImage.cxx | 93 +++++++++++++++++++++ src/gipfel.cxx | 11 +-- 9 files changed, 170 insertions(+), 264 deletions(-) delete mode 100644 src/DataImage.H delete mode 100644 src/DataImage.cxx create mode 100644 src/PreviewOutputImage.H create mode 100644 src/PreviewOutputImage.cxx (limited to 'src') diff --git a/src/DataImage.H b/src/DataImage.H deleted file mode 100644 index 1846857..0000000 --- a/src/DataImage.H +++ /dev/null @@ -1,55 +0,0 @@ -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// - -#ifndef DATAIMAGE_H -#define DATAIMAGE_H - -#include -#include - -class DataImage : public Fl_Widget { - private: - int d; - uchar *data; - - - public: - DataImage(int X, int Y, int W, int H, int channels=3); - - ~DataImage(); - - int set_pixel(int x, int y, char r, char g, char b); - - void draw(); - - int write_jpeg(const char *file, int quality); - - int write_tiff(const char *file); - - static int get_pixel(Fl_Image *img, int x, int y, - char *r, char *g, char *b); - - static int get_pixel_bilinear(Fl_Image *img, double x, double y, - char *r, char *g, char *b); - - static int get_pixel_nearest(Fl_Image *img, double x, double y, - char *r, char *g, char *b); -}; - -#endif diff --git a/src/DataImage.cxx b/src/DataImage.cxx deleted file mode 100644 index 21aa226..0000000 --- a/src/DataImage.cxx +++ /dev/null @@ -1,198 +0,0 @@ -// -// DataImage routines. -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// - -#include -#include -#include -#include -extern "C" { -#include -#include -} - -#include - -#include "DataImage.H" - -DataImage::DataImage(int X, int Y, int W, int H, int channels): Fl_Widget(X, Y, W, H) { - d = channels; - data = (uchar*) malloc(W * H * d); - memset(data, 0, W * H * d); -} - -DataImage::~DataImage() { - -} - - -int -DataImage::set_pixel(int x, int y, char r, char g, char b) { - if (x < 0 || x >= w() || y < 0 || y >= h()) { - return 1; - } - - long index = (y * w() * d + (x * d)); // X/Y -> buf index - *(data+index+0) = r; - *(data+index+1) = g; - *(data+index+2) = b; - if (d == 4) { - *(data+index+3) = 255; - } - - return 0; -} - - -void -DataImage::draw() { - fl_push_clip(x(), y(), w(), h()); - - fl_draw_image(data, x(), y(), w(), h(), d); - - fl_pop_clip(); -} - -int -DataImage::get_pixel_bilinear(Fl_Image *img, double x, double y, - char *r, char *g, char *b) { - - -} - -int -DataImage::get_pixel_nearest(Fl_Image *img, double x, double y, - char *r, char *g, char *b) { - if (isnan(x) || isnan(y)) { - return 1; - } else { - return get_pixel(img, (int) rint(x), (int) rint(y), r, g, b); - } -} - -int -DataImage::get_pixel(Fl_Image *img, int x, int y, - char *r, char *g, char *b) { - if ( img->d() == 0 ) { - return 1; - } - - if (x < 0 || x >=img->w() || y < 0 || y >= img->h()) { - return 1; - } - long index = (y * img->w() * img->d()) + (x * img->d()); // X/Y -> buf index - switch ( img->count() ) { - case 1: { // bitmap - const char *buf = img->data()[0]; - switch ( img->d() ) { - case 1: { // 8bit - *r = *g = *b = *(buf+index); - break; - } - case 3: // 24bit - *r = *(buf+index+0); - *g = *(buf+index+1); - *b = *(buf+index+2); - break; - default: // ?? - printf("Not supported: chans=%d\n", img->d()); - return 1; - } - break; - } - default: // ?? pixmap, bit vals - printf("Not supported: count=%d\n", img->count()); - exit(1); - } - - return 0; -} - - -int -DataImage::write_jpeg(const char *file, int quality) { - struct jpeg_compress_struct cinfo; - struct jpeg_error_mgr jerr; - FILE *outfile; - JSAMPROW row_pointer[1]; - int row_stride; - - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_compress(&cinfo); - - if ((outfile = fopen(file, "wb")) == NULL) { - fprintf(stderr, "can't open %s\n", file); - return 1; - } - - jpeg_stdio_dest(&cinfo, outfile); - cinfo.image_width = w(); - cinfo.image_height = h(); - cinfo.input_components = 3; /* # of color components per pixel */ - cinfo.in_color_space = JCS_RGB; - - jpeg_set_defaults(&cinfo); - jpeg_set_quality(&cinfo, quality, TRUE); - - jpeg_start_compress(&cinfo, TRUE); - - row_stride = w() * d; /* JSAMPLEs per row in image_buffer */ - while (cinfo.next_scanline < cinfo.image_height) { - row_pointer[0] = & data[cinfo.next_scanline * row_stride]; - jpeg_write_scanlines(&cinfo, row_pointer, 1); - } - - jpeg_finish_compress(&cinfo); - fclose(outfile); - jpeg_destroy_compress(&cinfo); - - return 0; -} - -int -DataImage::write_tiff(const char *file) { - TIFF *output; - uint32 width, height; - char *raster; - - // Open the output image - if((output = TIFFOpen(file, "w")) == NULL){ - fprintf(stderr, "can't open %s\n", file); - return 1; - } - - // Write the tiff tags to the file - TIFFSetField(output, TIFFTAG_IMAGEWIDTH, w()); - TIFFSetField(output, TIFFTAG_IMAGELENGTH, h()); - TIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE); - TIFFSetField(output, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - TIFFSetField(output, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); - TIFFSetField(output, TIFFTAG_BITSPERSAMPLE, 8); - TIFFSetField(output, TIFFTAG_SAMPLESPERPIXEL, d); - - // Actually write the image - if(TIFFWriteEncodedStrip(output, 0, data, w() * h() * d) == 0){ - fprintf(stderr, "Could not write image\n"); - return 2; - } - - TIFFClose(output); - return 0; -} diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H index 50cb10d..4e74cb4 100644 --- a/src/GipfelWidget.H +++ b/src/GipfelWidget.H @@ -52,6 +52,9 @@ class GipfelWidget : public Fl_Widget { static int get_pixel_nearest(Fl_Image *img, double x, double y, char *r, char *g, char *b); + static int get_pixel(Fl_Image *img, int x, int y, + char *r, char *g, char *b); + public: GipfelWidget(int X,int Y,int W, int H); diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index 34716e0..c4fe032 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -770,11 +770,18 @@ GipfelWidget::get_pixel(double a_view, double a_nick, int GipfelWidget::get_pixel_nearest(Fl_Image *img, double x, double y, - char *r, char *g, char *b) { - if (isnan(x) || isnan(y)) { - return 1; - } + char *r, char *g, char *b) { + if (isnan(x) || isnan(y)) { + return 1; + } else { + return get_pixel(img, (int) rint(x), (int) rint(y), r, g, b); + } +} + +int +GipfelWidget::get_pixel(Fl_Image *img, int x, int y, + char *r, char *g, char *b) { if ( img->d() == 0 ) { return 1; } diff --git a/src/Makefile.am b/src/Makefile.am index 466b772..b686716 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,7 +14,8 @@ gipfel_SOURCES = \ choose_hill.cxx \ Stitch.cxx \ OutputImage.cxx \ - JPEGOutputImage.cxx + JPEGOutputImage.cxx \ + PreviewOutputImage.cxx noinst_HEADERS = \ GipfelWidget.H \ @@ -30,4 +31,5 @@ noinst_HEADERS = \ Stitch.H \ OutputImage.H \ JPEGOutputImage.H \ + PreviewOutputImage.H \ util.h diff --git a/src/OutputImage.H b/src/OutputImage.H index 9a99548..e7ab4e5 100644 --- a/src/OutputImage.H +++ b/src/OutputImage.H @@ -23,7 +23,7 @@ class OutputImage { private: - int w, h, initialized, line; + int W, H, initialized, line; public: OutputImage(); diff --git a/src/PreviewOutputImage.H b/src/PreviewOutputImage.H new file mode 100644 index 0000000..02e60c5 --- /dev/null +++ b/src/PreviewOutputImage.H @@ -0,0 +1,53 @@ +// +// Copyright 2006 by Johannes Hofmann +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// + +#ifndef PREVIEWOUTPUTIMAGE_H +#define PREVIEWOUTPUTIMAGE_H + +#include + +#include +#include + +#include "OutputImage.H" + +class PreviewOutputImage : OutputImage , public Fl_Widget { + private: + uchar *data; + int d; + int row; + + public: + PreviewOutputImage(int X, int Y, int W, int H); + + ~PreviewOutputImage(); + + void draw(); + + protected: + int init_internal(int w, int h); + + int set_pixel_internal(int x, char r, char g, char b); + + int next_line_internal(); + + int done_internal(); +}; + +#endif diff --git a/src/PreviewOutputImage.cxx b/src/PreviewOutputImage.cxx new file mode 100644 index 0000000..ba86edc --- /dev/null +++ b/src/PreviewOutputImage.cxx @@ -0,0 +1,93 @@ +// +// DataImage routines. +// +// Copyright 2006 by Johannes Hofmann +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// + +#include +#include +#include + +#include +#include + +#include "PreviewOutputImage.H" + +PreviewOutputImage::PreviewOutputImage(int X, int Y, int W, int H): Fl_Widget(X, Y, W, H) { + d = 3; + data = NULL; +} + +PreviewOutputImage::~PreviewOutputImage() { + if (data) { + free(data); + } +} + +int +PreviewOutputImage::init_internal(int w, int h) { + data = (uchar*) malloc(w * h * d); + memset(data, 0, w * h * d); + row = 0; + size(w, h); + return 0; +} + + + +int +PreviewOutputImage::set_pixel_internal(int x, char r, char g, char b) { + if (!data) { + return 1; + } + + long index = (row * w() * d + (x * d)); + *(data+index+0) = r; + *(data+index+1) = g; + *(data+index+2) = b; + + return 0; +} + +int +PreviewOutputImage::next_line_internal() { + row++; + if (row % (h() / 100) == 0) { + redraw(); + Fl::check(); + } + return 0; +} + +int +PreviewOutputImage::done_internal() { + return 0; +} + +void +PreviewOutputImage::draw() { + if (!data) { + return; + } + fl_push_clip(x(), y(), w(), h()); + + fl_draw_image(data, x(), y(), w(), h(), d); + + fl_pop_clip(); +} + diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 5cd170a..5dd69a7 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -42,6 +42,7 @@ #include "Fl_Search_Chooser.H" #include "GipfelWidget.H" #include "JPEGOutputImage.H" +#include "PreviewOutputImage.H" #include "Stitch.H" #include "choose_hill.H" #include "../config.h" @@ -448,18 +449,18 @@ static int stitch(int stitch_w, int stitch_h, int argc, char **argv) { for (int i=0; iload_image(argv[i]); } -#if 0 + win = new Fl_Window(0,0, 1000, stitch_h); scroll = new Fl_Scroll(0, 0, win->w(), win->h()); - PreviewOutputImage *img = new PreviewOutputImage(); + PreviewOutputImage *img = new PreviewOutputImage(0, 0, stitch_w, stitch_h); win->resizable(scroll); win->show(0, argv); - st->resample(img, 0.0, 7.0); -#endif - st->set_output((OutputImage*) new JPEGOutputImage("/tmp/bla.jpg", 90)); + //st->set_output((OutputImage*) new JPEGOutputImage("/tmp/bla.jpg", 90)); + st->set_output((OutputImage*) img); st->resample(stitch_w, stitch_h, 0.0, 7.0); + img->redraw(); Fl::run(); return 0; -- cgit v1.2.3 From f2e115a29f85d8d637f2e0894532212e93691118 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Wed, 2 Aug 2006 18:06:28 +0200 Subject: cleanup --- src/OutputImage.H | 4 +++- src/PreviewOutputImage.H | 1 - src/PreviewOutputImage.cxx | 6 ++---- src/gipfel.cxx | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/OutputImage.H b/src/OutputImage.H index e7ab4e5..a7f01f5 100644 --- a/src/OutputImage.H +++ b/src/OutputImage.H @@ -23,7 +23,7 @@ class OutputImage { private: - int W, H, initialized, line; + int initialized; public: OutputImage(); @@ -39,6 +39,8 @@ class OutputImage { int done(); protected: + int W, H, line; + virtual int init_internal(int w1, int h1); virtual int set_pixel_internal(int x, char r, char g, char b); diff --git a/src/PreviewOutputImage.H b/src/PreviewOutputImage.H index 02e60c5..7095999 100644 --- a/src/PreviewOutputImage.H +++ b/src/PreviewOutputImage.H @@ -31,7 +31,6 @@ class PreviewOutputImage : OutputImage , public Fl_Widget { private: uchar *data; int d; - int row; public: PreviewOutputImage(int X, int Y, int W, int H); diff --git a/src/PreviewOutputImage.cxx b/src/PreviewOutputImage.cxx index ba86edc..078ba26 100644 --- a/src/PreviewOutputImage.cxx +++ b/src/PreviewOutputImage.cxx @@ -43,7 +43,6 @@ int PreviewOutputImage::init_internal(int w, int h) { data = (uchar*) malloc(w * h * d); memset(data, 0, w * h * d); - row = 0; size(w, h); return 0; } @@ -56,7 +55,7 @@ PreviewOutputImage::set_pixel_internal(int x, char r, char g, char b) { return 1; } - long index = (row * w() * d + (x * d)); + long index = (line * w() * d + (x * d)); *(data+index+0) = r; *(data+index+1) = g; *(data+index+2) = b; @@ -66,8 +65,7 @@ PreviewOutputImage::set_pixel_internal(int x, char r, char g, char b) { int PreviewOutputImage::next_line_internal() { - row++; - if (row % (h() / 100) == 0) { + if (line % 10 == 0) { redraw(); Fl::check(); } diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 5dd69a7..8256cd8 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -450,7 +450,7 @@ static int stitch(int stitch_w, int stitch_h, int argc, char **argv) { st->load_image(argv[i]); } - win = new Fl_Window(0,0, 1000, stitch_h); + win = new Fl_Window(0,0, stitch_w, stitch_h); scroll = new Fl_Scroll(0, 0, win->w(), win->h()); PreviewOutputImage *img = new PreviewOutputImage(0, 0, stitch_w, stitch_h); win->resizable(scroll); -- cgit v1.2.3 From 699556f7efcf6a9af39c37bd0c881ee3edc21da3 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Wed, 2 Aug 2006 18:21:54 +0200 Subject: add JPEGOutputImage.cxx --- src/JPEGOutputImage.H | 1 - src/JPEGOutputImage.cxx | 118 ++++++++++++++++++++++++++++++++++++++++++++++++ src/gipfel.cxx | 4 +- 3 files changed, 120 insertions(+), 3 deletions(-) create mode 100644 src/JPEGOutputImage.cxx (limited to 'src') diff --git a/src/JPEGOutputImage.H b/src/JPEGOutputImage.H index 31bdd76..50570e5 100644 --- a/src/JPEGOutputImage.H +++ b/src/JPEGOutputImage.H @@ -32,7 +32,6 @@ class JPEGOutputImage : OutputImage { private: unsigned char *row; char *file; - int w, h; struct jpeg_compress_struct cinfo; struct jpeg_error_mgr jerr; FILE *fp; diff --git a/src/JPEGOutputImage.cxx b/src/JPEGOutputImage.cxx new file mode 100644 index 0000000..09fd4c6 --- /dev/null +++ b/src/JPEGOutputImage.cxx @@ -0,0 +1,118 @@ +// +// Copyright 2006 by Johannes Hofmann +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// + +#include +#include +#include +extern "C" { +#include +} + +#include "JPEGOutputImage.H" + +JPEGOutputImage::JPEGOutputImage(const char *f, int quality) { + file = strdup(f); + fp = NULL; + row = NULL; +} + +JPEGOutputImage::~JPEGOutputImage() { + if (row) { + free(row); + } + if (file) { + free(file); + } +} + +int +JPEGOutputImage::init_internal(int w1, int h1) { + if (row) { + free(row); + row = NULL; + } + + row = (unsigned char*) malloc(sizeof(char) * 3 * W); + if (!row) { + perror("malloc"); + return 1; + } + memset(row, 0, sizeof(char) * 3 * W); + + if (fp) { + fclose(fp); + } + + if ((fp = fopen(file, "wb")) == NULL) { + fprintf(stderr, "can't open %s\n", file); + return 1; + } + + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_compress(&cinfo); + jpeg_stdio_dest(&cinfo, fp); + cinfo.image_width = W; + cinfo.image_height = H; + cinfo.input_components = 3; /* # of color components per pixel */ + cinfo.in_color_space = JCS_RGB; + + jpeg_set_defaults(&cinfo); + jpeg_set_quality(&cinfo, quality, TRUE); + + jpeg_start_compress(&cinfo, TRUE); + +} + +int +JPEGOutputImage::set_pixel_internal(int x, char r, char g, char b) { + row[x*3+0] = r; + row[x*3+1] = g; + row[x*3+2] = b; + + return 0; +} + +int +JPEGOutputImage::next_line_internal() { + JSAMPROW row_pointer[1]; + + row_pointer[0] = row; + jpeg_write_scanlines(&cinfo, &row_pointer, 1); + memset(row, 0, sizeof(char) * 3 * W); + return 0; +} + +int +JPEGOutputImage::done_internal() { + next_line_internal(); + jpeg_finish_compress(&cinfo); + fclose(fp); + fp = NULL; + jpeg_destroy_compress(&cinfo); + if (row) { + free(row); + } + + if (fp) { + fclose(fp); + fp = NULL; + } + return 0; +} + diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 8256cd8..8e0e1b9 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -457,8 +457,8 @@ static int stitch(int stitch_w, int stitch_h, int argc, char **argv) { win->show(0, argv); - //st->set_output((OutputImage*) new JPEGOutputImage("/tmp/bla.jpg", 90)); - st->set_output((OutputImage*) img); + st->set_output((OutputImage*) new JPEGOutputImage("/tmp/bla.jpg", 90)); + //st->set_output((OutputImage*) img); st->resample(stitch_w, stitch_h, 0.0, 7.0); img->redraw(); Fl::run(); -- cgit v1.2.3 From 61903e6014daa0e381ffee5ae5c4599fb303eb01 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Wed, 2 Aug 2006 18:24:56 +0200 Subject: make things compile again --- src/JPEGOutputImage.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/JPEGOutputImage.cxx b/src/JPEGOutputImage.cxx index 09fd4c6..d801166 100644 --- a/src/JPEGOutputImage.cxx +++ b/src/JPEGOutputImage.cxx @@ -93,7 +93,7 @@ JPEGOutputImage::next_line_internal() { JSAMPROW row_pointer[1]; row_pointer[0] = row; - jpeg_write_scanlines(&cinfo, &row_pointer, 1); + jpeg_write_scanlines(&cinfo, row_pointer, 1); memset(row, 0, sizeof(char) * 3 * W); return 0; } -- cgit v1.2.3 From 4894107e215fd13e8121bcdc3b610c4db7556689 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Thu, 3 Aug 2006 17:38:41 +0200 Subject: really use JPEG quality --- src/JPEGOutputImage.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/JPEGOutputImage.cxx b/src/JPEGOutputImage.cxx index d801166..9e00458 100644 --- a/src/JPEGOutputImage.cxx +++ b/src/JPEGOutputImage.cxx @@ -26,10 +26,11 @@ extern "C" { #include "JPEGOutputImage.H" -JPEGOutputImage::JPEGOutputImage(const char *f, int quality) { +JPEGOutputImage::JPEGOutputImage(const char *f, int q) { file = strdup(f); fp = NULL; row = NULL; + quality = q; } JPEGOutputImage::~JPEGOutputImage() { -- cgit v1.2.3 From 6524c95bb8ea0339908ab9bff03211f8c42e77d9 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Thu, 3 Aug 2006 20:45:57 +0200 Subject: add TIFFOutputImage --- src/JPEGOutputImage.cxx | 8 ++- src/Makefile.am | 2 + src/OutputImage.cxx | 179 ++++++++++++++++++++++++++++++++++++++++++++++++ src/TIFFOutputImage.H | 49 +++++++++++++ src/TIFFOutputImage.cxx | 110 +++++++++++++++++++++++++++++ src/gipfel.cxx | 95 +++++++++++++++---------- 6 files changed, 402 insertions(+), 41 deletions(-) create mode 100644 src/OutputImage.cxx create mode 100644 src/TIFFOutputImage.H create mode 100644 src/TIFFOutputImage.cxx (limited to 'src') diff --git a/src/JPEGOutputImage.cxx b/src/JPEGOutputImage.cxx index 9e00458..3f7fd11 100644 --- a/src/JPEGOutputImage.cxx +++ b/src/JPEGOutputImage.cxx @@ -101,11 +101,13 @@ JPEGOutputImage::next_line_internal() { int JPEGOutputImage::done_internal() { - next_line_internal(); jpeg_finish_compress(&cinfo); - fclose(fp); - fp = NULL; jpeg_destroy_compress(&cinfo); + + if (fp) { + fclose(fp); + fp = NULL; + } if (row) { free(row); } diff --git a/src/Makefile.am b/src/Makefile.am index b686716..5577090 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,6 +15,7 @@ gipfel_SOURCES = \ Stitch.cxx \ OutputImage.cxx \ JPEGOutputImage.cxx \ + TIFFOutputImage.cxx \ PreviewOutputImage.cxx noinst_HEADERS = \ @@ -31,5 +32,6 @@ noinst_HEADERS = \ Stitch.H \ OutputImage.H \ JPEGOutputImage.H \ + TIFFOutputImage.H \ PreviewOutputImage.H \ util.h diff --git a/src/OutputImage.cxx b/src/OutputImage.cxx new file mode 100644 index 0000000..52af058 --- /dev/null +++ b/src/OutputImage.cxx @@ -0,0 +1,179 @@ +// +// Copyright 2006 by Johannes Hofmann +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// + +#include +#include + +#include "OutputImage.H" + +OutputImage::OutputImage() { + W = 0; + H = 0; + initialized = 0; +} + +OutputImage::~OutputImage() { +} + +int +OutputImage::init(int w1, int h1) { + W = w1; + H = h1; + line = 0; + initialized = 1; + + return init_internal(w1, h1); +} + + +int +OutputImage::init_internal(int w1, int h1) { + return 0; +} + +int +OutputImage::set_pixel(int x, char r, char g, char b) { + if (!initialized || x < 0 || x >= W) { + return 1; + } else { + return set_pixel_internal(x, r, g, b); + } +} + +int +OutputImage::set_pixel_internal(int x, char r, char g, char b) { + return 0; +} + +int +OutputImage::next_line() { + if (!initialized || line++ >= H) { + return 1; + } else { + return next_line_internal(); + } +} + +int +OutputImage::next_line_internal() { + return 0; +} + +int +OutputImage::done() { + if (!initialized) { + return 1; + } else { + next_line(); + return done_internal(); + } +} + +int +OutputImage::done_internal() { + return 0; +} + +#define MAX_OUTPUT_IMAGES 16 +OutputImages::OutputImages() { + imgs = (OutputImage **) calloc(MAX_OUTPUT_IMAGES, sizeof(OutputImage *)); + max_imgs = MAX_OUTPUT_IMAGES; +} + +OutputImages::~OutputImages() { + free(imgs); +} + +int +OutputImages::add(OutputImage *img) { + for (int i=0; iinit(w, h); + } + } + + return ret; +} + +int +OutputImages::set_pixel(int x, char r, char g, char b) { + int ret = 0; + + for (int i=0; iset_pixel(x, r, g, b); + } + } + + return ret; +} + +int +OutputImages::next_line() { + int ret = 0; + + for (int i=0; inext_line(); + } + } + + return ret; +} + +int +OutputImages::done() { + int ret = 0; + + for (int i=0; idone(); + } + } + + return ret; +} + diff --git a/src/TIFFOutputImage.H b/src/TIFFOutputImage.H new file mode 100644 index 0000000..3a14279 --- /dev/null +++ b/src/TIFFOutputImage.H @@ -0,0 +1,49 @@ +// +// Copyright 2006 by Johannes Hofmann +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// + +#ifndef TIFFOUTPUTIMAGE_H +#define TIFFOUTPUTIMAGE_H + +#include +#include + +#include "OutputImage.H" + +class TIFFOutputImage : OutputImage { + private: + unsigned char *row; + char *file; + TIFF *tiff; + + public: + TIFFOutputImage(const char *file); + + ~TIFFOutputImage(); + + protected: + int init_internal(int w, int h); + + int set_pixel_internal(int x, char r, char g, char b); + + int next_line_internal(); + + int done_internal(); +}; + +#endif diff --git a/src/TIFFOutputImage.cxx b/src/TIFFOutputImage.cxx new file mode 100644 index 0000000..ed9213f --- /dev/null +++ b/src/TIFFOutputImage.cxx @@ -0,0 +1,110 @@ +// +// Copyright 2006 by Johannes Hofmann +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// + +#include +#include +#include + +#include "TIFFOutputImage.H" + +TIFFOutputImage::TIFFOutputImage(const char *f) { + file = strdup(f); + tiff = NULL; + row = NULL; +} + +TIFFOutputImage::~TIFFOutputImage() { + if (row) { + free(row); + } + if (file) { + free(file); + } +} + +int +TIFFOutputImage::init_internal(int w1, int h1) { + if (row) { + free(row); + row = NULL; + } + + row = (unsigned char*) malloc(sizeof(char) * 4 * w1); + if (!row) { + perror("malloc"); + return 1; + } + memset(row, 0, sizeof(char) * 4 * w1); + + if (tiff) { + TIFFClose(tiff); + } + + if((tiff = TIFFOpen(file, "w")) == NULL){ + fprintf(stderr, "can't open %s\n", file); + return 1; + } + + TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, w1); + TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, h1); + TIFFSetField(tiff, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE); + TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); + TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8); + TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 4); + + return 0; +} + +int +TIFFOutputImage::set_pixel_internal(int x, char r, char g, char b) { + row[x*4+0] = r; + row[x*4+1] = g; + row[x*4+2] = b; + row[x*4+3] = 255; + + return 0; +} + +int +TIFFOutputImage::next_line_internal() { + int ret; + ret = TIFFWriteScanline(tiff, row, line-1, 0); + if (ret != 1) { + fprintf(stderr, "TIFFWriteScanline failed\n"); + } + memset(row, 0, sizeof(char) * 4 * W); + return 0; +} + +int +TIFFOutputImage::done_internal() { + if (tiff) { + TIFFClose(tiff); + tiff = NULL; + } + + if (row) { + free(row); + row = NULL; + } + + return 0; +} + diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 8e0e1b9..74b092a 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -42,6 +42,7 @@ #include "Fl_Search_Chooser.H" #include "GipfelWidget.H" #include "JPEGOutputImage.H" +#include "TIFFOutputImage.H" #include "PreviewOutputImage.H" #include "Stitch.H" #include "choose_hill.H" @@ -63,7 +64,11 @@ Fl_Value_Input *i_view_lat, *i_view_long, *i_view_height; Fl_Box *b_viewpoint; Fl_Menu_Bar *mb; -static int stitch(int stitch_w, int stitch_h, int argc, char **argv); +#define STITCH_PREVIEW 1 +#define STITCH_JPEG 2 +#define STITCH_TIFF 4 +static int stitch(int stitch_w, int stitch_h, int type, const char *path, + int argc, char **argv); void set_values() { s_center->value(gipf->get_center_angle()); @@ -325,14 +330,16 @@ int main(int argc, char** argv) { char *view_point = NULL; int err, bflag = 0, dflag = 0, my_argc; int stitch_flag = 0, stitch_w = 2000, stitch_h = 500; + int jpeg_flag = 0, tiff_flag = 0; + char *outpath; Fl_Window *control_win, *view_win; Fl_Scroll *scroll; err = 0; - while ((c = getopt(argc, argv, "d:v:sw:b:")) != EOF) { + while ((c = getopt(argc, argv, "?d:v:sw:h:j:t:")) != EOF) { switch (c) { - case 'h': + case '?': usage(); exit(0); break; @@ -345,10 +352,18 @@ int main(int argc, char** argv) { case 's': stitch_flag++; break; + case 'j': + jpeg_flag++; + outpath = optarg; + break; + case 't': + tiff_flag++; + outpath = optarg; + break; case 'w': stitch_w = atoi(optarg); break; - case 'b': + case 'h': stitch_h = atoi(optarg); break; default: @@ -370,7 +385,13 @@ int main(int argc, char** argv) { } if (stitch_flag) { - stitch(stitch_w, stitch_h, my_argc, my_argv); + int type = STITCH_PREVIEW; + if (jpeg_flag) { + type = STITCH_JPEG; + } else if (tiff_flag) { + type = STITCH_TIFF; + } + stitch(stitch_w, stitch_h, type, outpath, my_argc, my_argv); exit(0); } @@ -419,29 +440,7 @@ int main(int argc, char** argv) { return Fl::run(); } -#if 0 -static int tiffstitch(int stitch_w, int stitch_h, int argc, char **argv) { - char buf[256]; - - for (int i=0; iload_image(argv[i]); - - st->resample(img, 0.0, 7.0); - snprintf(buf, sizeof(buf), "gipfel_%d.tiff", i); - img->write_tiff(buf); - delete st; - delete img; - } - - return 0; -} -#endif - - -static int stitch(int stitch_w, int stitch_h, int argc, char **argv) { +static int stitch(int stitch_w, int stitch_h, int type, const char *path, int argc, char **argv) { Fl_Window *win; Fl_Scroll *scroll; Stitch *st = new Stitch(); @@ -449,19 +448,39 @@ static int stitch(int stitch_w, int stitch_h, int argc, char **argv) { for (int i=0; iload_image(argv[i]); } + + if (type == STITCH_JPEG) { + + st->set_output((OutputImage*) new JPEGOutputImage(path, 90)); + st->resample(stitch_w, stitch_h, 0.0, 7.0); + + } else if (type == STITCH_TIFF) { - win = new Fl_Window(0,0, stitch_w, stitch_h); - scroll = new Fl_Scroll(0, 0, win->w(), win->h()); - PreviewOutputImage *img = new PreviewOutputImage(0, 0, stitch_w, stitch_h); - win->resizable(scroll); + for (int i=0; ishow(0, argv); + snprintf(buf, sizeof(buf), "%s/%s", path, argv[i]); + dot = strrchr(buf, '.'); + *dot = '\0'; + strncat(buf, ".tiff", sizeof(buf)); - st->set_output((OutputImage*) new JPEGOutputImage("/tmp/bla.jpg", 90)); - //st->set_output((OutputImage*) img); - st->resample(stitch_w, stitch_h, 0.0, 7.0); - img->redraw(); - Fl::run(); + st->set_output(argv[i], (OutputImage*) new TIFFOutputImage(buf)); + } + + st->resample(stitch_w, stitch_h, 0.0, 7.0); + + } else { + win = new Fl_Window(0,0, stitch_w, stitch_h); + scroll = new Fl_Scroll(0, 0, win->w(), win->h()); + PreviewOutputImage *img = new PreviewOutputImage(0, 0, stitch_w, stitch_h); + win->resizable(scroll); + win->show(0, argv); + st->set_output((OutputImage*) img); + st->resample(stitch_w, stitch_h, 0.0, 7.0); + img->redraw(); + Fl::run(); + } return 0; } -- cgit v1.2.3 From 641efabfea98270beef8b7f8a472b8d9e6f0c3aa Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Thu, 3 Aug 2006 20:50:47 +0200 Subject: adjust usage --- src/gipfel.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 74b092a..139b850 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -211,12 +211,16 @@ void fill_menubar(Fl_Menu_Bar* mb) { void usage() { fprintf(stderr, - "usage: gipfel [-v ] [-d ] []\n" + "usage: gipfel [-v ] [-d ]\n" + " [-s] [-j ] [-t ]\n" " -v Set point from which the picture was taken.\n" " This must be a string that unambiguously \n" " matches the name of an entry in the data file.\n" " -d Use for GPS data.\n" - " JPEG file to use.\n"); + " -s Stitch mode.\n" + " -j JPEG output file for Stitch mode.\n" + " -t Output directory for TIFF images in Stitch mode.\n" + " JPEG file(s) to use.\n"); } Fl_Window * -- cgit v1.2.3 From b289453edc8c3f83824b2e2964779de0bad148a7 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Thu, 3 Aug 2006 20:53:10 +0200 Subject: remove OutputImages --- src/OutputImage.H | 23 -------------- src/OutputImage.cxx | 87 ----------------------------------------------------- 2 files changed, 110 deletions(-) (limited to 'src') diff --git a/src/OutputImage.H b/src/OutputImage.H index a7f01f5..8792eb6 100644 --- a/src/OutputImage.H +++ b/src/OutputImage.H @@ -50,27 +50,4 @@ class OutputImage { virtual int done_internal(); }; -class OutputImages { - private: - OutputImage **imgs; - int max_imgs; - - public: - OutputImages(); - - ~OutputImages(); - - int add(OutputImage *img); - - int remove(OutputImage *img); - - int init(int w, int h); - - int set_pixel(int x, char r, char g, char b); - - int next_line(); - - int done(); -}; - #endif diff --git a/src/OutputImage.cxx b/src/OutputImage.cxx index 52af058..f2e7296 100644 --- a/src/OutputImage.cxx +++ b/src/OutputImage.cxx @@ -90,90 +90,3 @@ OutputImage::done_internal() { return 0; } -#define MAX_OUTPUT_IMAGES 16 -OutputImages::OutputImages() { - imgs = (OutputImage **) calloc(MAX_OUTPUT_IMAGES, sizeof(OutputImage *)); - max_imgs = MAX_OUTPUT_IMAGES; -} - -OutputImages::~OutputImages() { - free(imgs); -} - -int -OutputImages::add(OutputImage *img) { - for (int i=0; iinit(w, h); - } - } - - return ret; -} - -int -OutputImages::set_pixel(int x, char r, char g, char b) { - int ret = 0; - - for (int i=0; iset_pixel(x, r, g, b); - } - } - - return ret; -} - -int -OutputImages::next_line() { - int ret = 0; - - for (int i=0; inext_line(); - } - } - - return ret; -} - -int -OutputImages::done() { - int ret = 0; - - for (int i=0; idone(); - } - } - - return ret; -} - -- cgit v1.2.3 From f3575d9ccfc61beca36ef40dc20b625cbc2f1368 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Thu, 3 Aug 2006 21:12:39 +0200 Subject: use TIFFWriteEncodedStrip instead of TIFFWriteScanline because of mem usage of libtiff. --- src/TIFFOutputImage.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/TIFFOutputImage.cxx b/src/TIFFOutputImage.cxx index ed9213f..b8433ca 100644 --- a/src/TIFFOutputImage.cxx +++ b/src/TIFFOutputImage.cxx @@ -66,6 +66,7 @@ TIFFOutputImage::init_internal(int w1, int h1) { TIFFSetField(tiff, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE); TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); + TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, 1); TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8); TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 4); @@ -85,10 +86,9 @@ TIFFOutputImage::set_pixel_internal(int x, char r, char g, char b) { int TIFFOutputImage::next_line_internal() { int ret; - ret = TIFFWriteScanline(tiff, row, line-1, 0); - if (ret != 1) { - fprintf(stderr, "TIFFWriteScanline failed\n"); - } + + TIFFWriteEncodedStrip(tiff, line -1 , row, W * 4); + memset(row, 0, sizeof(char) * 4 * W); return 0; } -- cgit v1.2.3 From 145d775aa43d49e5f9de30f51bd88c0f0f46183c Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Thu, 3 Aug 2006 21:26:37 +0200 Subject: update README and usage --- src/gipfel.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 139b850..9755f2e 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -212,7 +212,8 @@ void fill_menubar(Fl_Menu_Bar* mb) { void usage() { fprintf(stderr, "usage: gipfel [-v ] [-d ]\n" - " [-s] [-j ] [-t ]\n" + " [-s] [-j ] [-t ] [-h ]\n" + " []\n" " -v Set point from which the picture was taken.\n" " This must be a string that unambiguously \n" " matches the name of an entry in the data file.\n" @@ -220,7 +221,7 @@ void usage() { " -s Stitch mode.\n" " -j JPEG output file for Stitch mode.\n" " -t Output directory for TIFF images in Stitch mode.\n" - " JPEG file(s) to use.\n"); + " JPEG file(s) to use.\n"); } Fl_Window * -- cgit v1.2.3 From feae8373e6fbdafe5368410ba0ac51059f7155f7 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Wed, 9 Aug 2006 22:19:00 +0200 Subject: Header and Copyright cleanup --- src/Fl_Search_Chooser.H | 4 ---- src/Fl_Value_Dial.H | 8 -------- src/Fl_Value_Dial.cxx | 4 ---- src/GipfelWidget.H | 4 +--- src/Hill.H | 2 -- src/Panorama.H | 2 -- src/Projection.H | 4 +--- src/ProjectionTangential.H | 2 -- src/choose_hill.H | 6 ------ 9 files changed, 2 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/Fl_Search_Chooser.H b/src/Fl_Search_Chooser.H index 6bb71fe..c87f0de 100644 --- a/src/Fl_Search_Chooser.H +++ b/src/Fl_Search_Chooser.H @@ -1,6 +1,4 @@ // -// "$Id: Fl_Value_Dial.H,v 1.2 2005/05/18 11:34:30 hofmann Exp $" -// // Value dial header file for the Fast Light Tool Kit (FLTK). // // Copyright 1998-2004 by Bill Spitzak and others. @@ -20,8 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 // USA. // -// Please report all bugs and problems to "fltk-bugs@fltk.org". -// #ifndef FL_SEARCH_CHOOSER_H #define FL_SEARCH_CHOOSER_H diff --git a/src/Fl_Value_Dial.H b/src/Fl_Value_Dial.H index 7d41aa5..f9ac18c 100644 --- a/src/Fl_Value_Dial.H +++ b/src/Fl_Value_Dial.H @@ -1,6 +1,4 @@ // -// "$Id: Fl_Value_Dial.H,v 1.2 2005/05/18 11:34:30 hofmann Exp $" -// // Value dial header file for the Fast Light Tool Kit (FLTK). // // Copyright 1998-2004 by Bill Spitzak and others. @@ -20,8 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 // USA. // -// Please report all bugs and problems to "fltk-bugs@fltk.org". -// #ifndef Fl_Value_Dial_H #define Fl_Value_Dial_H @@ -45,7 +41,3 @@ class Fl_Value_Dial : public Fl_Dial { }; #endif - -// -// End of "$Id: Fl_Value_Dial.H,v 1.2 2005/05/18 11:34:30 hofmann Exp $". -// diff --git a/src/Fl_Value_Dial.cxx b/src/Fl_Value_Dial.cxx index 6e5c35c..c837930 100644 --- a/src/Fl_Value_Dial.cxx +++ b/src/Fl_Value_Dial.cxx @@ -1,6 +1,4 @@ // -// "$Id: Fl_Value_Dial.cxx,v 1.2 2005/05/18 11:34:30 hofmann Exp $" -// // Value dial widget for the Fast Light Tool Kit (FLTK). // // Copyright 1998-2004 by Bill Spitzak and others. @@ -20,8 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 // USA. // -// Please report all bugs and problems to "fltk-bugs@fltk.org". -// #include #include diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H index 4e74cb4..7bcd3c0 100644 --- a/src/GipfelWidget.H +++ b/src/GipfelWidget.H @@ -1,7 +1,5 @@ // -// "$Id: GipfelWidget.H,v 1.22 2005/06/22 19:47:19 hofmann Exp $" -// -// Copyright 2005 by Johannes Hofmann +// Copyright 2006 by Johannes Hofmann // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public diff --git a/src/Hill.H b/src/Hill.H index fde7a89..13d7d64 100644 --- a/src/Hill.H +++ b/src/Hill.H @@ -1,6 +1,4 @@ // -// "$Id: Hill.H,v 1.16 2005/06/22 20:40:35 hofmann Exp $" -// // Copyright 2005 by Johannes Hofmann // // This library is free software; you can redistribute it and/or diff --git a/src/Panorama.H b/src/Panorama.H index 20d3213..a538809 100644 --- a/src/Panorama.H +++ b/src/Panorama.H @@ -1,6 +1,4 @@ // -// "$Id: Panorama.H,v 1.20 2005/06/22 19:47:20 hofmann Exp $" -// // Copyright 2005 by Johannes Hofmann // // This library is free software; you can redistribute it and/or diff --git a/src/Projection.H b/src/Projection.H index f6de5ae..0a6ec81 100644 --- a/src/Projection.H +++ b/src/Projection.H @@ -1,7 +1,5 @@ // -// "$Id: Panorama.H,v 1.20 2005/06/22 19:47:20 hofmann Exp $" -// -// Copyright 2005 by Johannes Hofmann +// Copyright 2006 by Johannes Hofmann // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public diff --git a/src/ProjectionTangential.H b/src/ProjectionTangential.H index 74a4b59..e74511f 100644 --- a/src/ProjectionTangential.H +++ b/src/ProjectionTangential.H @@ -1,6 +1,4 @@ // -// "$Id: Panorama.H,v 1.20 2005/06/22 19:47:20 hofmann Exp $" -// // Copyright 2005 by Johannes Hofmann // // This library is free software; you can redistribute it and/or diff --git a/src/choose_hill.H b/src/choose_hill.H index 1387868..e424d70 100644 --- a/src/choose_hill.H +++ b/src/choose_hill.H @@ -1,8 +1,4 @@ // -// "$Id: Fl_Value_Dial.H,v 1.2 2005/05/18 11:34:30 hofmann Exp $" -// -// Value dial header file for the Fast Light Tool Kit (FLTK). -// // Copyright 1998-2004 by Bill Spitzak and others. // // This library is free software; you can redistribute it and/or @@ -20,8 +16,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 // USA. // -// Please report all bugs and problems to "fltk-bugs@fltk.org". -// #ifndef CHOOSE_HILL_H #define CHOOSE_HILL_H -- cgit v1.2.3