Author: abrander
Date: 2009-11-30 18:24:55 +0100 (Mon, 30 Nov 2009)
New Revision: 2767

Added:
   trunk/librawstudio/rs-color-space-icc.c
   trunk/librawstudio/rs-color-space-icc.h
Modified:
   trunk/librawstudio/Makefile.am
   trunk/librawstudio/rawstudio.h
Log:
Added RSColorSpaceIcc to initiate a RSColorSpace from an ICC profile.

Modified: trunk/librawstudio/Makefile.am
===================================================================
--- trunk/librawstudio/Makefile.am      2009-11-30 16:54:40 UTC (rev 2766)
+++ trunk/librawstudio/Makefile.am      2009-11-30 17:24:55 UTC (rev 2767)
@@ -15,6 +15,7 @@
        rs-1d-function.h \
        rs-icc-profile.h \
        rs-color-space.h \
+       rs-color-space-icc.h \
        rs-image.h \
        rs-image16.h \
        rs-lens.h \
@@ -52,6 +53,7 @@
        rs-1d-function.c rs-1d-function.h \
        rs-icc-profile.c rs-icc-profile.h \
        rs-color-space.c rs-color-space.h \
+       rs-color-space-icc.c rs-color-space-icc.h \
        rs-image.c rs-image.h \
        rs-image16.c rs-image16.h \
        rs-lens.c rs-lens.h \

Modified: trunk/librawstudio/rawstudio.h
===================================================================
--- trunk/librawstudio/rawstudio.h      2009-11-30 16:54:40 UTC (rev 2766)
+++ trunk/librawstudio/rawstudio.h      2009-11-30 17:24:55 UTC (rev 2767)
@@ -35,6 +35,7 @@
 #include "rs-1d-function.h"
 #include "rs-icc-profile.h"
 #include "rs-color-space.h"
+#include "rs-color-space-icc.h"
 #include "rs-image.h"
 #include "rs-image16.h"
 #include "rs-metadata.h"

Added: trunk/librawstudio/rs-color-space-icc.c
===================================================================
--- trunk/librawstudio/rs-color-space-icc.c                             (rev 0)
+++ trunk/librawstudio/rs-color-space-icc.c     2009-11-30 17:24:55 UTC (rev 
2767)
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2006-2009 Anders Brander <[email protected]> and 
+ * Anders Kvist <[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"
+
+G_DEFINE_TYPE(RSColorSpaceIcc, rs_color_space_icc, RS_TYPE_COLOR_SPACE)
+
+static const RSIccProfile *get_icc_profile(const RSColorSpace *color_space);
+
+static void
+rs_color_space_icc_dispose(GObject *object)
+{
+       RSColorSpaceIcc *color_space_icc = RS_COLOR_SPACE_ICC(object);
+
+       if (!color_space_icc->dispose_has_run)
+       {
+               color_space_icc->dispose_has_run = TRUE;
+               if (color_space_icc->icc_profile)
+                       g_object_unref(color_space_icc->icc_profile);
+       }
+       G_OBJECT_CLASS(rs_color_space_icc_parent_class)->dispose(object);
+}
+
+static void
+rs_color_space_icc_class_init(RSColorSpaceIccClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS(klass);
+       object_class->dispose = rs_color_space_icc_dispose;
+       RSColorSpaceClass *colorclass = RS_COLOR_SPACE_CLASS(klass);
+
+       colorclass->get_icc_profile = get_icc_profile;
+       colorclass->name = "ICC derived color space";
+       colorclass->description = "ICC derived color space";
+}
+
+static void
+rs_color_space_icc_init(RSColorSpaceIcc *color_space_icc)
+{
+}
+
+RSColorSpace *
+rs_color_space_icc_new_from_icc(RSIccProfile *icc_profile)
+{
+       RSColorSpaceIcc *color_space_icc = 
g_object_new(RS_TYPE_COLOR_SPACE_ICC, NULL);
+
+       if (RS_IS_ICC_PROFILE(icc_profile))
+       {
+               color_space_icc->icc_profile = icc_profile;
+               /* FIXME: Some profiles will be nothing more than a fancy 
container
+                * for a color spaces definition, we should recognize those 
cases and
+                * try to convert them to RSColorSpace without the need for a 
CMS */
+               RS_COLOR_SPACE(color_space_icc)->flags |= 
RS_COLOR_SPACE_FLAG_REQUIRES_CMS;
+       }
+
+       return RS_COLOR_SPACE(color_space_icc);
+}
+
+RSColorSpace *
+rs_color_space_icc_new_from_file(const gchar *path)
+{
+       RSIccProfile *icc_profile = rs_icc_profile_new_from_file(path);
+       return rs_color_space_icc_new_from_icc(icc_profile);
+}
+
+static const
+RSIccProfile *get_icc_profile(const RSColorSpace *color_space)
+{
+       RSColorSpaceIcc *color_space_icc = RS_COLOR_SPACE_ICC(color_space);
+
+       return color_space_icc->icc_profile;
+}

Added: trunk/librawstudio/rs-color-space-icc.h
===================================================================
--- trunk/librawstudio/rs-color-space-icc.h                             (rev 0)
+++ trunk/librawstudio/rs-color-space-icc.h     2009-11-30 17:24:55 UTC (rev 
2767)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2006-2009 Anders Brander <[email protected]> and 
+ * Anders Kvist <[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_COLOR_SPACE_ICC_H
+#define RS_COLOR_SPACE_ICC_H
+
+#include <glib-object.h>
+#include "rs-color-space.h"
+
+G_BEGIN_DECLS
+
+#define RS_TYPE_COLOR_SPACE_ICC rs_color_space_icc_get_type()
+#define RS_COLOR_SPACE_ICC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
RS_TYPE_COLOR_SPACE_ICC, RSColorSpaceIcc))
+#define RS_COLOR_SPACE_ICC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), 
RS_TYPE_COLOR_SPACE_ICC, RSColorSpaceIccClass))
+#define RS_IS_COLOR_SPACE_ICC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
RS_TYPE_COLOR_SPACE_ICC))
+#define RS_IS_COLOR_SPACE_ICC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), 
RS_TYPE_COLOR_SPACE_ICC))
+#define RS_COLOR_SPACE_ICC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), 
RS_TYPE_COLOR_SPACE_ICC, RSColorSpaceIccClass))
+
+typedef struct {
+       RSColorSpace parent;
+       gboolean dispose_has_run;
+
+       RSIccProfile *icc_profile;
+} RSColorSpaceIcc;
+
+typedef struct {
+       RSColorSpaceClass parent_class;
+} RSColorSpaceIccClass;
+
+GType rs_color_space_icc_get_type(void);
+
+RSColorSpaceIcc *rs_color_space_icc_new_from_profile(RSIccProfile 
*icc_profile);
+
+RSColorSpace *rs_color_space_icc_new_from_file(const gchar *path);
+
+G_END_DECLS
+
+#endif /* RS_COLOR_SPACE_ICC_H */


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

Reply via email to