gegl r2581 - in trunk: . operations/external
- From: hub svn gnome org
- To: svn-commits-list gnome org
- Subject: gegl r2581 - in trunk: . operations/external
- Date: Sat, 16 Aug 2008 23:56:08 +0000 (UTC)
Author: hub
Date: Sat Aug 16 23:56:08 2008
New Revision: 2581
URL: http://svn.gnome.org/viewvc/gegl?rev=2581&view=rev
Log:
* operations/external/openraw.c:
* operations/external/Makefile.am:
* configure.ac:
RAW loader using libopenraw. Libopenraw is now an optional
dependency.
Added:
trunk/operations/external/openraw.c
Modified:
trunk/ChangeLog
trunk/configure.ac
trunk/operations/external/Makefile.am
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Sat Aug 16 23:56:08 2008
@@ -711,6 +711,20 @@
####################
+# Check for libopenraw
+####################
+
+dnl check for libopenraw
+PKG_CHECK_MODULES(OPENRAW, libopenraw-1.0,
+ have_openraw="yes",
+ have_openraw="no (usable libopenraw not found)")
+AM_CONDITIONAL(HAVE_OPENRAW, test "x$have_openraw" = "xyes")
+
+AC_SUBST(OPENRAW_CFLAGS)
+AC_SUBST(OPENRAW_LIBS)
+
+
+####################
# Check for graphviz
####################
@@ -879,6 +893,7 @@
OpenEXR: $have_openexr
rsvg: $have_librsvg
SDL: $have_sdl
+ openraw: $have_openraw
asciidoc: $have_asciidoc
enscript: $have_enscript
graphviz: $have_graphviz
Modified: trunk/operations/external/Makefile.am
==============================================================================
--- trunk/operations/external/Makefile.am (original)
+++ trunk/operations/external/Makefile.am Sat Aug 16 23:56:08 2008
@@ -60,6 +60,13 @@
display_la_CFLAGS = $(SDL_CFLAGS)
endif
+if HAVE_OPENRAW
+ops += openraw.la
+openraw_la_SOURCES = openraw.c
+openraw_la_LIBADD = $(op_libs) $(OPENRAW_LIBS)
+openraw_la_CFLAGS = $(OPENRAW_CFLAGS)
+endif
+
if HAVE_V4L
ops += v4l.la
v4l_la_SOURCES = v4l.c
Added: trunk/operations/external/openraw.c
==============================================================================
--- (empty file)
+++ trunk/operations/external/openraw.c Sat Aug 16 23:56:08 2008
@@ -0,0 +1,202 @@
+/* This file is an image processing operation for GEGL
+ *
+ * GEGL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * GEGL 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2006 Ãyvind KolÃs <pippin gimp org>
+ * Copyright 2008 Hubert FiguiÃre <hub figuiere net>
+ */
+
+
+#ifdef GEGL_CHANT_PROPERTIES
+
+gegl_chant_path (path, "File", "", "Path of file to load.")
+
+#else
+
+#define GEGL_CHANT_TYPE_SOURCE
+#define GEGL_CHANT_C_FILE "openraw.c"
+
+#include "gegl-chant.h"
+#include <stdio.h>
+#include <libopenraw/libopenraw.h>
+
+static gint
+query_raw (const gchar *path,
+ gint *width,
+ gint *height)
+{
+ or_error err;
+ uint32_t x, y;
+ ORRawDataRef rawdata;
+ or_data_type raw_format = OR_DATA_TYPE_NONE;
+ ORRawFileRef rawfile = or_rawfile_new(path, OR_RAWFILE_TYPE_UNKNOWN);
+
+ if (!rawfile) {
+ return 1;
+ }
+
+ rawdata = or_rawdata_new();
+ err = or_rawfile_get_rawdata(rawfile, rawdata, OR_OPTIONS_NONE);
+ if(err == OR_ERROR_NONE) {
+ raw_format = or_rawdata_format(rawdata);
+ if(raw_format == OR_DATA_TYPE_CFA) {
+ or_rawdata_dimensions(rawdata, &x, &y);
+ *width = x;
+ *height = y;
+ }
+ }
+
+ or_rawdata_release(rawdata);
+ or_rawfile_release(rawfile);
+ return ((err != OR_ERROR_NONE) || (raw_format != OR_DATA_TYPE_CFA));
+}
+
+
+static gint
+gegl_buffer_import_raw (GeglBuffer *gegl_buffer,
+ const gchar *path,
+ gint dest_x,
+ gint dest_y)
+{
+ ORRawDataRef rawdata;
+ or_data_type raw_format = OR_DATA_TYPE_NONE;
+ ORRawFileRef rawfile = or_rawfile_new(path, OR_RAWFILE_TYPE_UNKNOWN);
+ or_error err;
+
+ if (!rawfile) {
+ return 1;
+ }
+
+ rawdata = or_rawdata_new();
+ err = or_rawfile_get_rawdata(rawfile, rawdata, OR_OPTIONS_NONE);
+
+ if(err != OR_ERROR_NONE) {
+ uint32_t x, y;
+ void *data;
+
+ raw_format = or_rawdata_format(rawdata);
+ if(raw_format == OR_DATA_TYPE_CFA) {
+ /* TODO take the dest_x and dest_y into account */
+ GeglRectangle rect = {0, 0, 0, 0};
+ or_rawdata_dimensions(rawdata, &x, &y);
+ rect.width = x;
+ rect.height = y;
+
+ data = or_rawdata_data(rawdata);
+ gegl_buffer_set(gegl_buffer, &rect, babl_format ("Y u16"),
+ data, GEGL_AUTO_ROWSTRIDE);
+ }
+ }
+ or_rawdata_release(rawdata);
+ or_rawfile_release(rawfile);
+ return ((err != OR_ERROR_NONE) || (raw_format != OR_DATA_TYPE_CFA));
+}
+
+
+static GeglRectangle
+get_bounding_box (GeglOperation *operation)
+{
+ GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
+ GeglRectangle result = {0,0,0,0};
+ gint width, height;
+ gint status;
+ gegl_operation_set_format (operation, "output", babl_format ("Y u16"));
+ status = query_raw (o->path, &width, &height);
+
+ if (status)
+ {
+ /*g_warning ("calc have rect of %s failed", o->path);*/
+ result.width = 10;
+ result.height = 10;
+ }
+ else
+ {
+ result.width = width;
+ result.height = height;
+ }
+
+ return result;
+}
+
+
+static gboolean
+process (GeglOperation *operation,
+ GeglBuffer *output,
+ const GeglRectangle *result)
+{
+ GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
+ GeglRectangle rect={0,0};
+ gint problem;
+
+ problem = query_raw (o->path, &rect.width, &rect.height);
+
+ if (problem)
+ {
+ g_warning ("%s failed to open file %s for reading.",
+ G_OBJECT_TYPE_NAME (operation), o->path);
+ return FALSE;
+ }
+
+
+ problem = gegl_buffer_import_raw (output, o->path, 0, 0);
+
+ if (problem)
+ {
+ g_warning ("%s failed to open file %s for reading.",
+ G_OBJECT_TYPE_NAME (operation), o->path);
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
+gegl_chant_class_init (GeglChantClass *klass)
+{
+ GeglOperationClass *operation_class;
+ GeglOperationSourceClass *source_class;
+
+ operation_class = GEGL_OPERATION_CLASS (klass);
+ source_class = GEGL_OPERATION_SOURCE_CLASS (klass);
+
+ source_class->process = process;
+ operation_class->get_bounding_box = get_bounding_box;
+
+ operation_class->name = "openraw-load";
+ operation_class->categories = "hidden";
+ operation_class->description = "Camera RAW image loader";
+
+ static gboolean done=FALSE;
+ if (done)
+ return;
+
+ /* query libopenraw instead. need a new API */
+ gegl_extension_handler_register (".cr2", "openraw-load");
+ gegl_extension_handler_register (".CR2", "openraw-load");
+ gegl_extension_handler_register (".crw", "openraw-load");
+ gegl_extension_handler_register (".CRW", "openraw-load");
+ gegl_extension_handler_register (".erf", "openraw-load");
+ gegl_extension_handler_register (".ERF", "openraw-load");
+ gegl_extension_handler_register (".mrw", "openraw-load");
+ gegl_extension_handler_register (".MRW", "openraw-load");
+ gegl_extension_handler_register (".nef", "openraw-load");
+ gegl_extension_handler_register (".NEF", "openraw-load");
+ gegl_extension_handler_register (".dng", "openraw-load");
+ gegl_extension_handler_register (".DNG", "openraw-load");
+
+ done = TRUE;
+}
+
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]