summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--src/GipfelWidget.H3
-rw-r--r--src/Makefile.am4
-rw-r--r--src/ScreenDump.H25
-rw-r--r--src/ScreenDump.cxx42
-rw-r--r--src/gipfel.cxx16
6 files changed, 86 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index 2e82f2c..0d19427 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ gipfel-0.2.9
* fsync() temporary file before rename().
* Add "Find Peak" dialog (right click on image).
* Show height in search dialog to distinguish peaks with equal names.
+* Added "File->Screen Dump" feature.
gipfel-0.2.8
* Fix issue with image saving on some platforms (reported by David Mitchell).
diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H
index 85de338..57ce337 100644
--- a/src/GipfelWidget.H
+++ b/src/GipfelWidget.H
@@ -7,8 +7,11 @@
#ifndef GipfelWidget_H
#define GipfelWidget_H
+#include <stdio.h>
+
#include <FL/Fl_Group.H>
#include <FL/Fl_Menu_Button.H>
+
#include "Panorama.H"
#include "ImageMetaData.H"
diff --git a/src/Makefile.am b/src/Makefile.am
index df932a8..acf66f5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,7 +17,8 @@ gipfel_SOURCES = \
JPEGOutputImage.cxx \
TIFFOutputImage.cxx \
PreviewOutputImage.cxx \
- ImageMetaData.cxx
+ ImageMetaData.cxx \
+ ScreenDump.cxx
noinst_HEADERS = \
GipfelWidget.H \
@@ -38,4 +39,5 @@ noinst_HEADERS = \
TIFFOutputImage.H \
PreviewOutputImage.H \
ImageMetaData.H \
+ ScreenDump.H \
util.h
diff --git a/src/ScreenDump.H b/src/ScreenDump.H
new file mode 100644
index 0000000..f527404
--- /dev/null
+++ b/src/ScreenDump.H
@@ -0,0 +1,25 @@
+//
+// Copyright 2009 Johannes Hofmann <Johannes.Hofmann@gmx.de>
+//
+// This software may be used and distributed according to the terms
+// of the GNU General Public License, incorporated herein by reference.
+
+#ifndef SCREENDUMP_H
+#define SCREENDUMP_H
+
+#include "GipfelWidget.H"
+#include "OutputImage.H"
+
+class ScreenDump {
+ private:
+ GipfelWidget *gipf;
+ unsigned char * rgb;
+
+ public:
+ ScreenDump(GipfelWidget *g);
+ ~ScreenDump();
+
+ int save(const char *file);
+};
+
+#endif
diff --git a/src/ScreenDump.cxx b/src/ScreenDump.cxx
new file mode 100644
index 0000000..20a038f
--- /dev/null
+++ b/src/ScreenDump.cxx
@@ -0,0 +1,42 @@
+#include <stdlib.h>
+
+#include <FL/Fl.H>
+#include <FL/x.H>
+#include <FL/fl_draw.H>
+
+#include "JPEGOutputImage.H"
+#include "ScreenDump.H"
+
+ScreenDump::ScreenDump(GipfelWidget *g) {
+ Fl_Offscreen offscreen;
+
+ gipf = g;
+ Fl::flush();
+ offscreen = fl_create_offscreen(gipf->w(), gipf->h());
+ fl_begin_offscreen(offscreen);
+ gipf->draw();
+ rgb = fl_read_image(NULL, 0, 0, gipf->w(), gipf->h());
+ fl_end_offscreen();
+ fl_delete_offscreen(offscreen);
+}
+
+ScreenDump::~ScreenDump() {
+ free(rgb);
+}
+
+int
+ScreenDump::save(const char *file) {
+ JPEGOutputImage out(file, 95);
+
+ out.init(gipf->w(), gipf->h());
+
+ for (int y = 0; y < gipf->h(); y++) {
+ for (int x = 0; x < gipf->w(); x++) {
+ unsigned char *px = &rgb[(y * gipf->w() + x) * 3];
+ out.set_pixel(x, px[0] * 255, px[1] * 255, px[2] * 255);
+ }
+ out.next_line();
+ }
+
+ out.done();
+}
diff --git a/src/gipfel.cxx b/src/gipfel.cxx
index e6d9f49..2b665b5 100644
--- a/src/gipfel.cxx
+++ b/src/gipfel.cxx
@@ -35,6 +35,7 @@
#include "TIFFOutputImage.H"
#include "PreviewOutputImage.H"
#include "Stitch.H"
+#include "ScreenDump.H"
#include "choose_hill.H"
#include "../config.h"
@@ -91,11 +92,11 @@ void set_values() {
i_view_height->value(gipf->get_view_height());
b_viewpoint->label(gipf->get_viewpoint());
if (gipf->projection() == ProjectionLSQ::RECTILINEAR) {
- mb->mode(8, FL_MENU_RADIO|FL_MENU_VALUE);
- mb->mode(9, FL_MENU_RADIO);
- } else {
mb->mode(9, FL_MENU_RADIO|FL_MENU_VALUE);
- mb->mode(8, FL_MENU_RADIO);
+ mb->mode(10, FL_MENU_RADIO);
+ } else {
+ mb->mode(10, FL_MENU_RADIO|FL_MENU_VALUE);
+ mb->mode(9, FL_MENU_RADIO);
}
gipf->get_distortion_params(&k0, &k1, &x0);
@@ -136,6 +137,12 @@ void save_cb() {
fl_message("ERROR: Saving image %s failed.", file);
}
+void dump_cb(Fl_Widget * o, void*) {
+ ScreenDump dmp(gipf);
+
+ dmp.save("/tmp/dmp.jpg");
+}
+
void focal_length_cb(Fl_Slider* o, void*) {
gipf->set_focal_length_35mm(o->value());
}
@@ -273,6 +280,7 @@ void fill_menubar(Fl_Menu_Bar* mb) {
mb->add("&File/&Save Image", FL_CTRL+'s', (Fl_Callback*)save_cb);
mb->add("&File/Choose &Viewpoint", FL_CTRL+'v', (Fl_Callback*)viewpoint_cb);
mb->add("&File/Load &Track", FL_CTRL+'t', (Fl_Callback*)track_cb);
+ mb->add("&File/Screen &Dump", FL_CTRL+'d', (Fl_Callback*)dump_cb);
mb->add("&File/&Quit", FL_CTRL+'q', (Fl_Callback*)quit_cb);
mb->add("&Projection/Normal Projection", 0, (Fl_Callback *)proj_cb,