Author: abrander
Date: 2010-04-03 03:12:06 +0200 (Sat, 03 Apr 2010)
New Revision: 3326
Added:
trunk/plugins/fuji-rotate/
trunk/plugins/fuji-rotate/Makefile.am
trunk/plugins/fuji-rotate/fuji-rotate.c
Modified:
trunk/configure.in
trunk/plugins/Makefile.am
trunk/plugins/load-dcraw/dcrawloader.c
trunk/src/application.c
trunk/src/application.h
Log:
[47] Added support for Fujifilm cameras.
Modified: trunk/configure.in
===================================================================
--- trunk/configure.in 2010-04-03 01:05:56 UTC (rev 3325)
+++ trunk/configure.in 2010-04-03 01:12:06 UTC (rev 3326)
@@ -119,6 +119,7 @@
plugins/demosaic/Makefile
plugins/denoise/Makefile
plugins/exposure-mask/Makefile
+plugins/fuji-rotate/Makefile
plugins/input-file/Makefile
plugins/input-image16/Makefile
plugins/lensfun/Makefile
Modified: trunk/plugins/Makefile.am
===================================================================
--- trunk/plugins/Makefile.am 2010-04-03 01:05:56 UTC (rev 3325)
+++ trunk/plugins/Makefile.am 2010-04-03 01:12:06 UTC (rev 3326)
@@ -10,6 +10,7 @@
demosaic \
denoise \
exposure-mask \
+ fuji-rotate \
input-file \
input-image16 \
lensfun \
Added: trunk/plugins/fuji-rotate/Makefile.am
===================================================================
--- trunk/plugins/fuji-rotate/Makefile.am (rev 0)
+++ trunk/plugins/fuji-rotate/Makefile.am 2010-04-03 01:12:06 UTC (rev
3326)
@@ -0,0 +1,21 @@
+plugindir = $(libdir)/rawstudio/plugins
+
+AM_CFLAGS =\
+ -Wall\
+ -O4
+
+AM_CXXFLAGS = $(AM_CFLAGS)
+
+INCLUDES = \
+ -DPACKAGE_DATA_DIR=\""$(datadir)"\" \
+ -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
+ @PACKAGE_CFLAGS@ \
+ -I../../librawstudio/
+
+lib_LTLIBRARIES = fuji_rotate.la
+
+libdir = $(datadir)/rawstudio/plugins/
+
+fuji_rotate_la_LIBADD = @PACKAGE_LIBS@
+fuji_rotate_la_LDFLAGS = -module -avoid-version
+fuji_rotate_la_SOURCES = fuji-rotate.c
Added: trunk/plugins/fuji-rotate/fuji-rotate.c
===================================================================
--- trunk/plugins/fuji-rotate/fuji-rotate.c (rev 0)
+++ trunk/plugins/fuji-rotate/fuji-rotate.c 2010-04-03 01:12:06 UTC (rev
3326)
@@ -0,0 +1,221 @@
+/*
+ * * Copyright (C) 2006-2010 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.
+ */
+
+/* Plugin tmpl version 5 */
+
+#include <rawstudio.h>
+#include <math.h>
+
+#define RS_TYPE_FUJI_ROTATE (rs_fuji_rotate_type)
+#define RS_FUJI_ROTATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
RS_TYPE_FUJI_ROTATE, RSFujiRotate))
+#define RS_FUJI_ROTATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
RS_TYPE_FUJI_ROTATE, RSFujiRotateClass))
+#define RS_IS_FUJI_ROTATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
RS_TYPE_FUJI_ROTATE))
+
+typedef struct _RSFujiRotate RSFujiRotate;
+typedef struct _RSFujiRotateClass RSFujiRotateClass;
+
+struct _RSFujiRotate {
+ RSFilter parent;
+
+ gchar *changeme;
+ gint fuji_width;
+};
+
+struct _RSFujiRotateClass {
+ RSFilterClass parent_class;
+};
+
+RS_DEFINE_FILTER(rs_fuji_rotate, RSFujiRotate)
+
+enum {
+ PROP_0,
+ PROP_CHANGEME
+};
+
+static void get_property (GObject *object, guint property_id, GValue *value,
GParamSpec *pspec);
+static void set_property (GObject *object, guint property_id, const GValue
*value, GParamSpec *pspec);
+static RSFilterResponse *get_image(RSFilter *filter, const RSFilterRequest
*request);
+static RSFilterResponse *get_size(RSFilter *filter, const RSFilterRequest
*request);
+
+static RSFilterClass *rs_fuji_rotate_parent_class = NULL;
+
+G_MODULE_EXPORT void
+rs_plugin_load(RSPlugin *plugin)
+{
+ rs_fuji_rotate_get_type(G_TYPE_MODULE(plugin));
+}
+
+static void
+rs_fuji_rotate_class_init(RSFujiRotateClass *klass)
+{
+ RSFilterClass *filter_class = RS_FILTER_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ rs_fuji_rotate_parent_class = g_type_class_peek_parent (klass);
+
+ object_class->get_property = get_property;
+ object_class->set_property = set_property;
+
+ g_object_class_install_property(object_class,
+ PROP_CHANGEME, g_param_spec_string (
+ "changeme",
+ "Changeme nick",
+ "Changeme blurb",
+ NULL,
+ G_PARAM_READWRITE)
+ );
+
+ filter_class->name = "FujiRotate filter";
+ filter_class->get_image = get_image;
+ filter_class->get_size = get_size;
+}
+
+static void
+rs_fuji_rotate_init(RSFujiRotate *fuji_rotate)
+{
+ fuji_rotate->changeme = NULL;
+ fuji_rotate->fuji_width = 0;
+}
+
+static void
+get_property(GObject *object, guint property_id, GValue *value, GParamSpec
*pspec)
+{
+// RSFujiRotate *fuji_rotate = RS_FUJI_ROTATE(object);
+
+ switch (property_id)
+ {
+ case PROP_CHANGEME:
+ g_value_get_string (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id,
pspec);
+ }
+}
+
+static void
+set_property(GObject *object, guint property_id, const GValue *value,
GParamSpec *pspec)
+{
+ RSFujiRotate *fuji_rotate = RS_FUJI_ROTATE(object);
+
+ switch (property_id)
+ {
+ case PROP_CHANGEME:
+ g_free(fuji_rotate->changeme);
+ fuji_rotate->changeme = g_value_dup_string(value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id,
pspec);
+ }
+}
+
+RS_IMAGE16 *
+do_rotate(RS_IMAGE16 *input, gint fuji_width)
+{
+ const gint colors = 3;
+ gint height = input->h;
+ gint width = input->w;
+ gint i, row, col;
+ gfloat r, c, fr, fc;
+ gint ur, uc;
+ gushort wide, high;
+
+ if (!fuji_width)
+ return g_object_ref(input);
+
+ fuji_width = (fuji_width - 1);
+ const gdouble step = sqrt(0.5);
+ wide = fuji_width / step;
+ high = (height - fuji_width) / step;
+
+ RS_IMAGE16 *output = rs_image16_new(wide, high, 3, 4);
+
+ for (row=0; row < high; row++)
+ {
+ for (col=0; col < wide; col++)
+ {
+ ur = r = fuji_width + (row-col)*step;
+ uc = c = (row+col)*step;
+
+ if (ur > height-2 || uc > width-2)
+ continue;
+
+ fr = r - ur;
+ fc = c - uc;
+
+ gushort *out = GET_PIXEL(output, col, row);
+ gushort *top = GET_PIXEL(input, uc, ur);
+ gushort *bottom = GET_PIXEL(input, uc, ur+1);
+ for (i=0; i < colors; i++)
+ {
+ out[i] =
+ (top[i] * (1-fc) +
top[input->pixelsize+i] * fc) * (1-fr)
+ + (bottom[i] * (1-fc) +
bottom[input->pixelsize+i] * fc) * fr;
+ }
+ }
+ }
+
+ return output;
+}
+
+static RSFilterResponse *
+get_image(RSFilter *filter, const RSFilterRequest *request)
+{
+ RSFujiRotate *fuji_rotate = RS_FUJI_ROTATE(filter);
+ RSFilterResponse *previous_response;
+ RSFilterResponse *response;
+ RS_IMAGE16 *input;
+ RS_IMAGE16 *output = NULL;
+
+ previous_response = rs_filter_get_image(filter->previous, request);
+
+ if (!rs_filter_param_get_integer(RS_FILTER_PARAM(previous_response),
"fuji-width", &fuji_rotate->fuji_width) || (fuji_rotate->fuji_width == 0))
+ return previous_response;
+
+ input = rs_filter_response_get_image(previous_response);
+ if (!RS_IS_IMAGE16(input))
+ return previous_response;
+
+ response = rs_filter_response_clone(previous_response);
+ g_object_unref(previous_response);
+ output = do_rotate(input, fuji_rotate->fuji_width);
+ rs_filter_response_set_image(response, output);
+ g_object_unref(output);
+
+ g_object_unref(input);
+ return response;
+}
+
+static RSFilterResponse *
+get_size(RSFilter *filter, const RSFilterRequest *request)
+{
+ gint fuji_width = 0;
+ RSFilterResponse *previous_response =
rs_filter_get_size(filter->previous, request);
+
+ /* If we have no specific fuji-width, just return previous response */
+ if (!rs_filter_param_get_integer(RS_FILTER_PARAM(previous_response),
"fuji-width", &fuji_width) || (fuji_width == 0))
+ return previous_response;
+
+ RSFilterResponse *response =
rs_filter_response_clone(previous_response);
+ g_object_unref(previous_response);
+
+ rs_filter_response_set_width(response, fuji_width / sqrt(0.5));
+ rs_filter_response_set_height(response,
(rs_filter_response_get_height(previous_response) - fuji_width) / sqrt(0.5));
+
+ return response;
+}
Modified: trunk/plugins/load-dcraw/dcrawloader.c
===================================================================
--- trunk/plugins/load-dcraw/dcrawloader.c 2010-04-03 01:05:56 UTC (rev
3325)
+++ trunk/plugins/load-dcraw/dcrawloader.c 2010-04-03 01:12:06 UTC (rev
3326)
@@ -184,6 +184,7 @@
{
dcraw_load_raw(raw);
rs_io_unlock();
+ rs_filter_param_set_integer(RS_FILTER_PARAM(response),
"fuji-width", raw->fuji_width);
image = convert(raw);
dcraw_close(raw);
}
@@ -222,4 +223,5 @@
rs_filetype_register_loader(".mef", "Mamiya", open_dcraw, 10,
RS_LOADER_FLAGS_RAW);
rs_filetype_register_loader(".3fr", "Hasselblad", open_dcraw, 10,
RS_LOADER_FLAGS_RAW);
rs_filetype_register_loader(".erf", "Epson", open_dcraw, 10,
RS_LOADER_FLAGS_RAW);
+ rs_filetype_register_loader(".raf", "Fujifilm", open_dcraw, 10,
RS_LOADER_FLAGS_RAW);
}
Modified: trunk/src/application.c
===================================================================
--- trunk/src/application.c 2010-04-03 01:05:56 UTC (rev 3325)
+++ trunk/src/application.c 2010-04-03 01:12:06 UTC (rev 3326)
@@ -261,7 +261,8 @@
/* Build basic filter chain */
rs->filter_input = rs_filter_new("RSInputImage16", NULL);
rs->filter_demosaic = rs_filter_new("RSDemosaic", rs->filter_input);
- rs->filter_demosaic_cache = rs_filter_new("RSCache",
rs->filter_demosaic);
+ rs->filter_fuji_rotate = rs_filter_new("RSFujiRotate",
rs->filter_demosaic);
+ rs->filter_demosaic_cache = rs_filter_new("RSCache",
rs->filter_fuji_rotate);
/* We need this for 100% zoom */
g_object_set(rs->filter_demosaic_cache, "ignore-roi", TRUE, NULL);
Modified: trunk/src/application.h
===================================================================
--- trunk/src/application.h 2010-04-03 01:05:56 UTC (rev 3325)
+++ trunk/src/application.h 2010-04-03 01:12:06 UTC (rev 3326)
@@ -72,6 +72,7 @@
/* Generic filter chain */
RSFilter *filter_input;
RSFilter *filter_demosaic;
+ RSFilter *filter_fuji_rotate;
RSFilter *filter_demosaic_cache;
RSFilter *filter_lensfun;
RSFilter *filter_rotate;
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit