Author: akv
Date: 2012-04-17 16:17:47 +0200 (Tue, 17 Apr 2012)
New Revision: 4177

Added:
   branches/4175-enfuse/src/rs-enfuse.c
   branches/4175-enfuse/src/rs-enfuse.h
Modified:
   branches/4175-enfuse/src/Makefile.am
   branches/4175-enfuse/src/rs-actions.c
   branches/4175-enfuse/src/ui.xml
Log:
Initial commit of Enfuse code.

Modified: branches/4175-enfuse/src/Makefile.am
===================================================================
--- branches/4175-enfuse/src/Makefile.am        2012-04-17 14:00:05 UTC (rev 
4176)
+++ branches/4175-enfuse/src/Makefile.am        2012-04-17 14:17:47 UTC (rev 
4177)
@@ -45,7 +45,8 @@
        rs-external-editor.c rs-external-editor.h \
        rs-dir-selector.c rs-dir-selector.h \
        rs-tag-gui.c rs-tag-gui.h\
-       rs-tethered-shooting.c rs-tethered-shooting.h
+       rs-tethered-shooting.c rs-tethered-shooting.h \
+       rs-enfuse.c rs-enfuse.h
 
 rawstudio_LDADD = ../librawstudio/librawstudio-@[email protected] @PACKAGE_LIBS@ 
@GCONF_LIBS@ @LENSFUN_LIBS@ @LIBGPHOTO2_LIBS@ @DBUS_LIBS@ $(INTLLIBS)
 

Modified: branches/4175-enfuse/src/rs-actions.c
===================================================================
--- branches/4175-enfuse/src/rs-actions.c       2012-04-17 14:00:05 UTC (rev 
4176)
+++ branches/4175-enfuse/src/rs-actions.c       2012-04-17 14:17:47 UTC (rev 
4177)
@@ -42,6 +42,7 @@
 #include "rs-camera-db.h"
 #include "rs-toolbox.h"
 #include "rs-tethered-shooting.h"
+#include "rs-enfuse.h"
 
 static GtkActionGroup *core_action_group = NULL;
 static GStaticMutex rs_actions_spinlock = G_STATIC_MUTEX_INIT;
@@ -1415,6 +1416,14 @@
        );
 }
 
+ACTION(enfuse)
+{
+  GList *selected_names = rs_store_get_selected_names(rs->store);
+  gchar *filename = rs_enfuse(selected_names);
+  g_list_free(selected_names);
+  rs_store_load_file(rs->store, filename);
+}
+
 RADIOACTION(right_popup)
 {
        rs_preview_widget_set_snapshot(RS_PREVIEW_WIDGET(rs->preview), 1, 
gtk_radio_action_get_current_value(radioaction));
@@ -1494,6 +1503,7 @@
        { "RotateCounterClockwise", RS_STOCK_ROTATE_COUNTER_CLOCKWISE, 
_("Rotate Counterclockwise"), "<alt>Left", NULL, 
ACTION_CB(rotate_counter_clockwise) },
        { "Flip", RS_STOCK_FLIP, _("Flip"), NULL, NULL, ACTION_CB(flip) },
        { "Mirror", RS_STOCK_MIRROR, _("Mirror"), NULL, NULL, ACTION_CB(mirror) 
},
+       { "Enfuse", NULL, _("Enfuse"), "<ctrl><alt>E", NULL, ACTION_CB(enfuse) 
},
 
        /* View menu */
        { "PreviousPhoto", GTK_STOCK_GO_BACK, _("_Previous Photo"), 
"<control>Left", NULL, ACTION_CB(previous_photo) },

Added: branches/4175-enfuse/src/rs-enfuse.c
===================================================================
--- branches/4175-enfuse/src/rs-enfuse.c                                (rev 0)
+++ branches/4175-enfuse/src/rs-enfuse.c        2012-04-17 14:17:47 UTC (rev 
4177)
@@ -0,0 +1,175 @@
+/*
+ * * Copyright (C) 2006-2011 Anders Brander <[email protected]>,
+ * * Anders Kvist <[email protected]> and Klaus Post <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ */
+
+#include <rawstudio.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <string.h>
+#include <config.h>
+#include <gettext.h>
+#include "rs-enfuse.h"
+#include <stdlib.h>
+#include <fcntl.h>
+#include "filename.h"
+#include <rs-store.h>
+#include "gtk-helper.h"
+#include "rs-photo.h"
+#include "rs-cache.h"
+
+GList * export_images(GList *files)
+{
+  gint num_selected = g_list_length(files);
+  gint i;
+  gchar *name;
+
+  GString *output_str = g_string_new(g_get_tmp_dir());
+  output_str = g_string_append(output_str, "/");
+  output_str = g_string_append(output_str, ".rawstudio-enfuse-");
+  GString *output_unique = NULL;
+
+  RSFilter *finput = rs_filter_new("RSInputImage16", NULL);
+  RSFilter *fdemosaic = rs_filter_new("RSDemosaic", finput);
+  RSFilter *ffujirotate = rs_filter_new("RSFujiRotate", fdemosaic);
+  RSFilter *frotate = rs_filter_new("RSRotate", ffujirotate);
+  RSFilter *fcrop = rs_filter_new("RSCrop", frotate);
+  RSFilter *ftransform_input = rs_filter_new("RSColorspaceTransform", fcrop);
+  RSFilter *fdcp= rs_filter_new("RSDcp", ftransform_input);
+  RSFilter *fcache = rs_filter_new("RSCache", fdcp);
+  RSFilter *fresample= rs_filter_new("RSResample", fcache);
+  RSFilter *fdenoise= rs_filter_new("RSDenoise", fresample);
+  RSFilter *ftransform_display = rs_filter_new("RSColorspaceTransform", 
fdenoise);
+  RSFilter *fend = ftransform_display;
+  
+  RSOutput *output = rs_output_new("RSJpegfile");
+
+  RS_PHOTO *photo = NULL;
+
+  GList *exported_names = NULL;
+
+  num_selected = g_list_length(files);
+  if (g_list_length(files))
+    {
+      for(i=0; i<num_selected; i++)
+       {
+         name = (gchar*) g_list_nth_data(files, i);
+         output_unique = g_string_new(output_str->str);
+         g_string_append_printf(output_unique, "%d", i);
+         output_unique = g_string_append(output_unique, ".jpg");
+         exported_names = g_list_append(exported_names, output_unique->str);
+
+         photo = rs_photo_load_from_file(name);
+         if (photo)
+           {
+             rs_metadata_load_from_file(photo->metadata, name);
+             rs_cache_load(photo);
+
+             GList *filters = g_list_append(NULL, fend);
+             rs_photo_apply_to_filters(photo, filters, 0); /* FIXME: hardcoded 
*/
+             g_list_free(filters);
+      
+             rs_filter_set_recursive(fend,
+                                     "image", photo->input_response,
+                                     "filename", photo->filename,
+                                     NULL);
+
+             if (g_object_class_find_property(G_OBJECT_GET_CLASS(output), 
"filename"))
+               g_object_set(output, "filename", output_unique->str, NULL);
+
+             rs_output_set_from_conf(output, "batch");
+             rs_output_execute(output, fend);
+           }
+       }
+    }
+  return exported_names;
+}
+
+GList * align_images (GList *files) {
+  gint num_selected = g_list_length(files);
+  gint i;
+  gchar *name;
+  GList *aligned_names = NULL;
+
+  if (g_list_length(files))
+    {
+      GString *command = g_string_new("align_image_stack -a 
/tmp/.rawstudio-enfuse-aligned- ");
+      for(i=0; i<num_selected; i++)
+       {
+         name = (gchar*) g_list_nth_data(files, i);
+         command = g_string_append(command, name);
+         command = g_string_append(command, " ");
+         aligned_names = g_list_append(aligned_names, g_strdup_printf 
("/tmp/.rawstudio-enfuse-aligned-%04d.tif", i));
+       }
+      printf("command: %s\n", command->str);
+      if (system(command->str));
+    }
+  return aligned_names;
+}
+
+void enfuse_images(GList *files, gchar *out) {
+  gint num_selected = g_list_length(files);
+  gint i;
+  gchar *name;
+
+  if (g_list_length(files))
+    {
+      GString *command = g_string_new("enfuse ");
+      for(i=0; i<num_selected; i++)
+       {
+         name = (gchar*) g_list_nth_data(files, i);
+         command = g_string_append(command, name);
+         command = g_string_append(command, " ");
+       }
+      //      command = g_string_append(command, "-d 16 -o /tmp/hdr.tif");
+      command = g_string_append(command, "-o ");
+      command = g_string_append(command, out);
+      printf("command: %s\n", command->str);
+      if(system(command->str));
+    }
+}
+
+gchar * rs_enfuse(GList *files)
+{
+  gint num_selected = g_list_length(files);
+  gint i;
+  gchar *name = NULL;
+  gchar *file = NULL;
+  GString *outname = g_string_new("");
+  GString *fullpath = NULL;
+
+  if (g_list_length(files))
+    {
+      for(i=0; i<num_selected; i++)
+       {
+         name = (gchar*) g_list_nth_data(files, i);
+         file = g_malloc(sizeof(char)*strlen(name));
+         sscanf(g_path_get_basename(name), "%[^.]", file);
+         outname = g_string_append(outname, file);
+         if (i+1 != num_selected)
+           outname = g_string_append(outname, "+");
+       }
+      fullpath = g_string_new(g_path_get_dirname(name));
+      fullpath = g_string_append(fullpath, "/");
+      fullpath = g_string_append(fullpath, outname->str);
+      fullpath = g_string_append(fullpath, ".tif");
+    }
+  GList *exported_names = export_images(files);
+  GList *aligned_names = align_images(exported_names);
+  enfuse_images(aligned_names, fullpath->str);
+  return fullpath->str;
+}

Added: branches/4175-enfuse/src/rs-enfuse.h
===================================================================
--- branches/4175-enfuse/src/rs-enfuse.h                                (rev 0)
+++ branches/4175-enfuse/src/rs-enfuse.h        2012-04-17 14:17:47 UTC (rev 
4177)
@@ -0,0 +1,27 @@
+/*
+ * * Copyright (C) 2006-2011 Anders Brander <[email protected]>, 
+ * * Anders Kvist <[email protected]> and Klaus Post <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ */
+
+#ifndef RS_ENFUSE_H
+#define RS_ENFUSE_H
+
+#include "application.h"
+
+extern gchar * rs_enfuse(GList *files);
+
+#endif /* RS_ENFUSE_H  */

Modified: branches/4175-enfuse/src/ui.xml
===================================================================
--- branches/4175-enfuse/src/ui.xml     2012-04-17 14:00:05 UTC (rev 4176)
+++ branches/4175-enfuse/src/ui.xml     2012-04-17 14:17:47 UTC (rev 4177)
@@ -43,6 +43,7 @@
    <menuitem action="RotateCounterClockwise" />
    <menuitem action="Flip" />
    <menuitem action="Mirror" />
+   <menuitem action="Enfuse" />
   </menu>
   <menu action="ViewMenu">
    <menuitem action="PreviousPhoto" />


_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit

Reply via email to