Author: akv
Date: 2011-01-02 17:20:55 +0100 (Sun, 02 Jan 2011)
New Revision: 3776
Added:
trunk/librawstudio/lens_fix.xml
trunk/librawstudio/rs-lens-fix.c
trunk/librawstudio/rs-lens-fix.h
Modified:
trunk/librawstudio/Makefile.am
Log:
Added lens-fixing - this will make a lens with varying aperture values
depending on actual focallength show up only once in lens editor.
Modified: trunk/librawstudio/Makefile.am
===================================================================
--- trunk/librawstudio/Makefile.am 2011-01-02 02:30:50 UTC (rev 3775)
+++ trunk/librawstudio/Makefile.am 2011-01-02 16:20:55 UTC (rev 3776)
@@ -32,6 +32,7 @@
rs-lens.h \
rs-lens-db.h \
rs-lens-db-editor.h \
+ rs-lens-fix.h \
rs-library.h\
rs-metadata.h \
rs-filetypes.h \
@@ -81,6 +82,7 @@
rs-lens.c rs-lens.h \
rs-lens-db.c rs-lens-db.h \
rs-lens-db-editor.c rs-lens-db-editor.h \
+ rs-lens-fix.c rs-lens-fix.h \
rs-metadata.c rs-metadata.h \
rs-filetypes.c rs-filetypes.h \
rs-filter.c rs-filter.h \
@@ -114,3 +116,6 @@
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = rawstudio-1.1.pc
+
+sharedir = $(datadir)/rawstudio/
+share_DATA = lens_fix.xml
Added: trunk/librawstudio/lens_fix.xml
===================================================================
--- trunk/librawstudio/lens_fix.xml (rev 0)
+++ trunk/librawstudio/lens_fix.xml 2011-01-02 16:20:55 UTC (rev 3776)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rawstudio-lens-fix>
+ <!-- Tamron AF 18-270mm f/3.5-6.3 Di II VC LD Aspherical (IF) -->
+ <lens id="37" min-focal="18" max-focal="270">
+ <max-aperture>3.6</max-aperture>
+ <min-aperture>22</min-aperture>
+ </lens>
+</rawstudio-lens-fix>
Added: trunk/librawstudio/rs-lens-fix.c
===================================================================
--- trunk/librawstudio/rs-lens-fix.c (rev 0)
+++ trunk/librawstudio/rs-lens-fix.c 2011-01-02 16:20:55 UTC (rev 3776)
@@ -0,0 +1,88 @@
+/*
+ * * 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.
+ */
+
+#include <rawstudio.h>
+#include <libxml/encoding.h>
+#include "config.h"
+#include "rs-lens-fix.h"
+
+gboolean
+rs_lens_fix(RSMetadata *meta)
+{
+ xmlDocPtr doc;
+ xmlNodePtr cur;
+ xmlNodePtr entry = NULL;
+ xmlChar *val;
+
+ gint lens_id;
+ gdouble min_focal, max_focal;
+
+ gchar *filename = g_build_filename(PACKAGE_DATA_DIR, PACKAGE,
"lens_fix.xml", NULL);
+
+ if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR))
+ {
+ g_warning("Cannot read lens fix file: %s ", filename);
+ return FALSE;
+ }
+
+ doc = xmlParseFile(filename);
+ if (!doc)
+ {
+ g_warning("Error parsing lens fix file: %s ", filename);
+ return FALSE;
+ }
+
+ cur = xmlDocGetRootElement(doc);
+ if (cur && (xmlStrcmp(cur->name, BAD_CAST "rawstudio-lens-fix") == 0))
+ {
+ cur = cur->xmlChildrenNode;
+ while(cur)
+ {
+ if ((!xmlStrcmp(cur->name, BAD_CAST "lens")))
+ {
+ lens_id = atoi((char *) xmlGetProp(cur,
BAD_CAST "id"));
+ min_focal = atof((char *) xmlGetProp(cur,
BAD_CAST "min-focal"));
+ max_focal = atof((char *) xmlGetProp(cur,
BAD_CAST "max-focal"));
+
+ if (lens_id == meta->lens_id && min_focal ==
meta->lens_min_focal && max_focal == meta->lens_max_focal)
+ {
+ entry = cur->xmlChildrenNode;
+ while (entry)
+ {
+ val = xmlNodeListGetString(doc,
entry->xmlChildrenNode, 1);
+ if (!xmlStrcmp(entry->name,
BAD_CAST "max-aperture"))
+ meta->lens_max_aperture
= atof((char *) val);
+ else if
(!xmlStrcmp(entry->name, BAD_CAST "min-aperture"))
+ meta->lens_min_aperture
= atof((char *) val);
+ xmlFree(val);
+ entry = entry->next;
+ }
+ xmlFreeDoc(doc);
+ return TRUE;
+ }
+ }
+ cur = cur->next;
+ }
+ }
+ else
+ g_warning("Did not recognize the format in %s", filename);
+
+ xmlFreeDoc(doc);
+ return FALSE;
+}
Added: trunk/librawstudio/rs-lens-fix.h
===================================================================
--- trunk/librawstudio/rs-lens-fix.h (rev 0)
+++ trunk/librawstudio/rs-lens-fix.h 2011-01-02 16:20:55 UTC (rev 3776)
@@ -0,0 +1,25 @@
+/*
+ * * 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.
+ */
+
+#ifndef RS_LENS_FIX_H
+#define RS_LENS_FIX_H
+
+gboolean rs_lens_fix(RSMetadata *meta);
+
+#endif /* RS_LENS_FIX_H */
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit