summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/DataImage.H15
-rw-r--r--src/DataImage.cxx29
-rw-r--r--src/GipfelWidget.H3
-rw-r--r--src/GipfelWidget.cxx17
-rw-r--r--src/Panorama.H2
-rw-r--r--src/Panorama.cxx15
-rw-r--r--src/Stitch.H5
-rw-r--r--src/Stitch.cxx30
8 files changed, 99 insertions, 17 deletions
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 <FL/Fl_Widget.H>
+#include <FL/Fl_Image.H>
-
-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 <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <math.h>
-#include "DataImage.H"
-
-DataImage::DataImage() {
+#include <Fl/fl_draw.h>
+#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 <FL/fl_draw.H>
#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; i<MAX_PICS; i++) {
+ gipf[i] = NULL;
+ }
}
Stitch::~Stitch() {
+ for (int i=0; i<MAX_PICS; i++) {
+ if (gipf[i]) {
+ delete(gipf[i]);
+ } else {
+ break;
+ }
+ }
+}
-}
+int
+Stitch::load_image(char *file) {
+ for (int i=0; i<MAX_PICS; i++) {
+ if (gipf[i] == NULL) {
+ gipf[i] = new GipfelWidget(0, 0, 800, 600);
+ gipf[i]->load_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) {
+
}