Author: abrander
Date: 2010-01-28 21:14:49 +0100 (Thu, 28 Jan 2010)
New Revision: 3113

Modified:
   branches/rawstudio-ng-color/src/application.c
   branches/rawstudio-ng-color/src/application.h
   branches/rawstudio-ng-color/src/rs-photo.c
   branches/rawstudio-ng-color/src/rs-photo.h
   branches/rawstudio-ng-color/src/rs-preview-widget.c
   branches/rawstudio-ng-color/src/rs-toolbox.c
Log:
Added VERY basic camera ICC profile support.

Modified: branches/rawstudio-ng-color/src/application.c
===================================================================
--- branches/rawstudio-ng-color/src/application.c       2010-01-28 18:40:05 UTC 
(rev 3112)
+++ branches/rawstudio-ng-color/src/application.c       2010-01-28 20:14:49 UTC 
(rev 3113)
@@ -45,6 +45,7 @@
 #include "lensfun.h"
 
 static void photo_spatial_changed(RS_PHOTO *photo, RS_BLOB *rs);
+static void photo_profile_changed(RS_PHOTO *photo, gpointer profile, RS_BLOB 
*rs);
 
 void
 rs_free(RS_BLOB *rs)
@@ -103,6 +104,7 @@
                        NULL);
 
                g_signal_connect(G_OBJECT(rs->photo), "spatial-changed", 
G_CALLBACK(photo_spatial_changed), rs);
+               g_signal_connect(G_OBJECT(rs->photo), "profile-changed", 
G_CALLBACK(photo_profile_changed), rs);
        }
 }
 
@@ -121,6 +123,30 @@
 
 }
 
+static void
+photo_profile_changed(RS_PHOTO *photo, gpointer profile, RS_BLOB *rs)
+{
+       if (photo == rs->photo)
+       {
+               if (RS_IS_ICC_PROFILE(profile))
+               {
+                       RSColorSpace *cs = 
rs_color_space_icc_new_from_icc(profile);
+
+                       g_object_set(rs->filter_input, "color-space", cs, NULL);
+
+                       /* We unref at once, and the the filter keep the only 
reference */
+                       g_object_unref(cs);
+               }
+               else
+               {
+                       /* If we don't have a specific ICC profile, we will 
simply assign
+                          a Prophoto colorspace to stop RSColorTransform from 
doing
+                          anything - this works because RSDcp is requesting 
Prophoto. */
+                       g_object_set(rs->filter_input, "color-space", 
rs_color_space_new_singleton("RSProphoto"), NULL);
+               }
+       }
+}
+
 gboolean
 rs_photo_save(RS_PHOTO *photo, RSOutput *output, gint width, gint height, 
gboolean keep_aspect, gdouble scale, gint snapshot, RS_CMS *cms)
 {

Modified: branches/rawstudio-ng-color/src/application.h
===================================================================
--- branches/rawstudio-ng-color/src/application.h       2010-01-28 18:40:05 UTC 
(rev 3112)
+++ branches/rawstudio-ng-color/src/application.h       2010-01-28 20:14:49 UTC 
(rev 3113)
@@ -51,6 +51,7 @@
        gdouble angle;
        gboolean exported;
        RSDcpFile *dcp;
+       RSIccProfile *icc;
        gboolean dispose_has_run;
 } RS_PHOTO;
 

Modified: branches/rawstudio-ng-color/src/rs-photo.c
===================================================================
--- branches/rawstudio-ng-color/src/rs-photo.c  2010-01-28 18:40:05 UTC (rev 
3112)
+++ branches/rawstudio-ng-color/src/rs-photo.c  2010-01-28 20:14:49 UTC (rev 
3113)
@@ -107,8 +107,8 @@
                0, /* Is this right? */
                NULL,
                NULL,
-               g_cclosure_marshal_VOID__OBJECT,
-               G_TYPE_NONE, 1, RS_TYPE_DCP_FILE);
+               g_cclosure_marshal_VOID__POINTER,
+               G_TYPE_NONE, 1, G_TYPE_POINTER);
 
        parent_class = g_type_class_peek_parent (klass);
 }
@@ -378,6 +378,7 @@
        g_assert(RS_IS_PHOTO(photo));
 
        photo->dcp = dcp;
+       photo->icc = NULL;
 
        g_signal_emit(photo, signals[PROFILE_CHANGED], 0, photo->dcp);
 }
@@ -395,6 +396,34 @@
 }
 
 /**
+ * Assign a ICC profile to a photo
+ * @param photo A RS_PHOTO
+ * @param dcp An ICC profile
+ */
+void
+rs_photo_set_icc_profile(RS_PHOTO *photo, RSIccProfile *icc)
+{
+       g_assert(RS_IS_PHOTO(photo));
+
+       photo->icc = icc;
+       photo->dcp = NULL;
+
+       g_signal_emit(photo, signals[PROFILE_CHANGED], 0, photo->icc);
+}
+
+/**
+ * Get the assigned ICC profile for a RS_PHOTO
+ * @param photo A RS_PHOTO
+ * @return An ICC profile or NULL
+ */
+RSIccProfile *rs_photo_get_icc_profile(RS_PHOTO *photo)
+{
+       g_assert(RS_IS_PHOTO(photo));
+
+       return photo->icc;
+}
+
+/**
  * Sets the white balance of a RS_PHOTO using warmth and tint variables
  * @param photo A RS_PHOTO
  * @param snapshot Which snapshot to affect

Modified: branches/rawstudio-ng-color/src/rs-photo.h
===================================================================
--- branches/rawstudio-ng-color/src/rs-photo.h  2010-01-28 18:40:05 UTC (rev 
3112)
+++ branches/rawstudio-ng-color/src/rs-photo.h  2010-01-28 20:14:49 UTC (rev 
3113)
@@ -239,6 +239,20 @@
 extern RSDcpFile *rs_photo_get_dcp_profile(RS_PHOTO *photo);
 
 /**
+ * Assign a ICC profile to a photo
+ * @param photo A RS_PHOTO
+ * @param dcp An ICC profile
+ */
+extern void rs_photo_set_icc_profile(RS_PHOTO *photo, RSIccProfile *icc);
+
+/**
+ * Get the assigned ICC profile for a RS_PHOTO
+ * @param photo A RS_PHOTO
+ * @return An ICC profile or NULL
+ */
+extern RSIccProfile *rs_photo_get_icc_profile(RS_PHOTO *photo);
+
+/**
  * Sets the white balance of a RS_PHOTO using warmth and tint variables
  * @param photo A RS_PHOTO
  * @param snapshot Which snapshot to affect

Modified: branches/rawstudio-ng-color/src/rs-preview-widget.c
===================================================================
--- branches/rawstudio-ng-color/src/rs-preview-widget.c 2010-01-28 18:40:05 UTC 
(rev 3112)
+++ branches/rawstudio-ng-color/src/rs-preview-widget.c 2010-01-28 20:14:49 UTC 
(rev 3113)
@@ -223,7 +223,7 @@
 static gboolean button(GtkWidget *widget, GdkEventButton *event, 
RSPreviewWidget *preview);
 static gboolean motion(GtkWidget *widget, GdkEventMotion *event, gpointer 
user_data);
 static gboolean leave(GtkWidget *widget, GdkEventCrossing *event, gpointer 
user_data);
-static void dcp_profile_changed(RS_PHOTO *photo, RSDcpFile *dcp, 
RSPreviewWidget *preview);
+static void profile_changed(RS_PHOTO *photo, gpointer profile, RSPreviewWidget 
*preview);
 static void settings_changed(RS_PHOTO *photo, RSSettingsMask mask, 
RSPreviewWidget *preview);
 static void filter_changed(RSFilter *filter, RSFilterChangedMask mask, 
RSPreviewWidget *preview);
 static gboolean get_image_coord(RSPreviewWidget *preview, gint view, const 
gint x, const gint y, gint *scaled_x, gint *scaled_y, gint *real_x, gint 
*real_y, gint *max_w, gint *max_h);
@@ -567,7 +567,10 @@
 
                        rs_filter_set_previous(preview->loupe_filter_start, 
preview->filter_input);
                        /* FIXME: view is hardcoded to 0 */
-                       g_object_set(preview->loupe_filter_dcp, "profile", 
rs_photo_get_dcp_profile(preview->photo), NULL);
+                       if (rs_photo_get_dcp_profile(preview->photo))
+                               g_object_set(preview->loupe_filter_dcp, 
"profile", rs_photo_get_dcp_profile(preview->photo), NULL);
+                       else
+                               g_object_set(preview->loupe_filter_dcp, 
"use-profile", FALSE, NULL);
                        rs_filter_set_recursive(preview->loupe_filter_end, 
"settings", preview->photo->settings[preview->snapshot[0]], NULL);
                        rs_loupe_set_colorspace(preview->loupe, 
preview->display_color_space);
 
@@ -607,7 +610,7 @@
        if (preview->photo)
        {
                g_signal_connect(G_OBJECT(preview->photo), "settings-changed", 
G_CALLBACK(settings_changed), preview);
-               g_signal_connect(G_OBJECT(preview->photo), "profile-changed", 
G_CALLBACK(dcp_profile_changed), preview);
+               g_signal_connect(G_OBJECT(preview->photo), "profile-changed", 
G_CALLBACK(profile_changed), preview);
                for(view=0;view<MAX_VIEWS;view++) 
                {
                        rs_filter_request_set_quick(preview->request[view], 
TRUE);
@@ -2249,7 +2252,7 @@
 }
 
 static void
-dcp_profile_changed(RS_PHOTO *photo, RSDcpFile *dcp, RSPreviewWidget *preview)
+profile_changed(RS_PHOTO *photo, gpointer profile, RSPreviewWidget *preview)
 {
        gint view;
 
@@ -2258,11 +2261,21 @@
                /* Set view profile */
                for(view=0;view<MAX_VIEWS;view++)
                {
-                       g_object_set(preview->filter_dcp[view], "profile", dcp, 
NULL);
+                       /* We should only deal with this, if it's DCP, ICC is 
catched elsewhere */
+                       if (RS_IS_DCP_FILE(profile))
+                               g_object_set(preview->filter_dcp[view], 
"profile", profile, NULL);
+                       else
+                               g_object_set(preview->filter_dcp[view], 
"use-profile", FALSE, NULL);
+
                        rs_filter_set_recursive(preview->filter_end[view], 
"settings", preview->photo->settings[preview->snapshot[view]], NULL);
                }
+
                /* Set navigator profile, uses view 0 */
-               g_object_set(preview->navigator_filter_dcp, "profile", dcp, 
NULL);
+               if (RS_IS_DCP_FILE(profile))
+                       g_object_set(preview->navigator_filter_dcp, "profile", 
profile, NULL);
+               else
+                       g_object_set(preview->navigator_filter_dcp, 
"use-profile", FALSE, NULL);
+
                rs_filter_set_recursive(preview->navigator_filter_end, 
"settings", preview->photo->settings[preview->snapshot[0]], NULL);
        }
 }

Modified: branches/rawstudio-ng-color/src/rs-toolbox.c
===================================================================
--- branches/rawstudio-ng-color/src/rs-toolbox.c        2010-01-28 18:40:05 UTC 
(rev 3112)
+++ branches/rawstudio-ng-color/src/rs-toolbox.c        2010-01-28 20:14:49 UTC 
(rev 3113)
@@ -235,7 +235,8 @@
 static void
 icc_profile_selected(RSProfileSelector *selector, RSIccProfile *icc, RSToolbox 
*toolbox)
 {
-       g_debug("FIXME: stub @ %s:%d %s()", __FILE__, __LINE__, __FUNCTION__);
+       if (toolbox->photo)
+               rs_photo_set_icc_profile(toolbox->photo, icc);
 }
 
 static void


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

Reply via email to