From 5e981a4ecb4b1a2c9f575a51e3c1a6a7ba98a7cc Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sat, 5 Jul 2008 23:02:19 +0200 Subject: fix PreviewOutputImage --- src/JPEGOutputImage.cxx | 2 +- src/PreviewOutputImage.H | 3 +-- src/PreviewOutputImage.cxx | 27 ++++++++------------------- src/Stitch.cxx | 25 +++++++++++-------------- src/TIFFOutputImage.cxx | 2 +- 5 files changed, 22 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/JPEGOutputImage.cxx b/src/JPEGOutputImage.cxx index 263eeb3..13022a9 100644 --- a/src/JPEGOutputImage.cxx +++ b/src/JPEGOutputImage.cxx @@ -13,7 +13,7 @@ extern "C" { #include "JPEGOutputImage.H" -JPEGOutputImage::JPEGOutputImage(const char *f, int q) { +JPEGOutputImage::JPEGOutputImage(const char *f, int q) : OutputImage() { file = strdup(f); fp = NULL; row = NULL; diff --git a/src/PreviewOutputImage.H b/src/PreviewOutputImage.H index b4bca3b..8351422 100644 --- a/src/PreviewOutputImage.H +++ b/src/PreviewOutputImage.H @@ -20,10 +20,9 @@ class PreviewOutputImage : public OutputImage , public Fl_Widget { int d; protected: - int init_internal(int w, int h); + int init_internal(); int set_pixel_internal(int x, int r, int g, int b); int next_line_internal(); - int done_internal(); public: PreviewOutputImage(int X, int Y, int W, int H); diff --git a/src/PreviewOutputImage.cxx b/src/PreviewOutputImage.cxx index 0ae182e..45cb898 100644 --- a/src/PreviewOutputImage.cxx +++ b/src/PreviewOutputImage.cxx @@ -13,32 +13,29 @@ #include "PreviewOutputImage.H" -PreviewOutputImage::PreviewOutputImage(int X, int Y, int W, int H): Fl_Widget(X, Y, W, H) { +PreviewOutputImage::PreviewOutputImage(int X, int Y, int W, int H): + OutputImage(), Fl_Widget(X, Y, W, H) { d = 3; data = NULL; } PreviewOutputImage::~PreviewOutputImage() { - if (data) { + if (data) free(data); - } } int -PreviewOutputImage::init_internal(int w, int h) { - data = (uchar*) malloc(w * h * d); - memset(data, 0, w * h * d); - size(w, h); +PreviewOutputImage::init_internal() { + data = (uchar*) malloc(W * H * d); + memset(data, 0, W * H * d); + size(W, H); return 0; } - - int PreviewOutputImage::set_pixel_internal(int x, int r, int g, int b) { - if (!data) { + if (!data) return 1; - } long index = (line * w() * d + (x * d)); *(data+index+0) = (unsigned char) (r / 255); @@ -57,20 +54,12 @@ PreviewOutputImage::next_line_internal() { 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/Stitch.cxx b/src/Stitch.cxx index 65a838e..3aefb20 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -98,15 +98,14 @@ Stitch::resample(GipfelWidget::sample_mode_t m, int merged_pixel_set; double radius = (double) w / (view_end -view_start); - if (merged_image) { - merged_image->init(w, h); - } + if (merged_image) + if (merged_image->init(w, h) != 0) + merged_image = NULL; - for (int i=0; iinit(w, h); - } - } + for (int i=0; iinit(w, h) != 0) + single_images[i] = NULL; for (int y = 0; y < h; y++) { double a_nick = atan((double)(y_off - y)/radius); @@ -146,14 +145,12 @@ Stitch::resample(GipfelWidget::sample_mode_t m, } } - if (merged_image) { + if (merged_image) merged_image->done(); - } - for (int i=0; idone(); - } - } return 0; } diff --git a/src/TIFFOutputImage.cxx b/src/TIFFOutputImage.cxx index 204bfa5..38dfd5b 100644 --- a/src/TIFFOutputImage.cxx +++ b/src/TIFFOutputImage.cxx @@ -10,7 +10,7 @@ #include "TIFFOutputImage.H" -TIFFOutputImage::TIFFOutputImage(const char *f, int b) { +TIFFOutputImage::TIFFOutputImage(const char *f, int b) : OutputImage () { bitspersample = (b==16)?16:8; file = strdup(f); tiff = NULL; -- cgit v1.2.3