[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50250] branches/soc-2011-tomato/source/ blender: Color management: display color managed RGB values in color sample line

Sergey Sharybin sergey.vfx at gmail.com
Mon Aug 27 17:23:15 CEST 2012


Revision: 50250
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50250
Author:   nazgul
Date:     2012-08-27 15:23:14 +0000 (Mon, 27 Aug 2012)
Log Message:
-----------
Color management: display color managed RGB values in color sample line

Makes it possible to investigate color managed ranges.

Not ideal but it's the quickest thing which could be done to remove
current grading stoppers for Mango.

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/editors/include/ED_image.h
    branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c
    branches/soc-2011-tomato/source/blender/editors/space_image/image_ops.c
    branches/soc-2011-tomato/source/blender/editors/space_node/node_view.c
    branches/soc-2011-tomato/source/blender/editors/space_sequencer/sequencer_view.c
    branches/soc-2011-tomato/source/blender/imbuf/IMB_colormanagement.h
    branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c

Modified: branches/soc-2011-tomato/source/blender/editors/include/ED_image.h
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/include/ED_image.h	2012-08-27 13:40:19 UTC (rev 50249)
+++ branches/soc-2011-tomato/source/blender/editors/include/ED_image.h	2012-08-27 15:23:14 UTC (rev 50250)
@@ -39,6 +39,7 @@
 struct uiBlock;
 struct wmWindowManager;
 struct ARegion;
+struct Scene;
 
 /* image_edit.c, exported for transform */
 struct Image *ED_space_image(struct SpaceImage *sima);
@@ -79,7 +80,7 @@
 /* UI level image (texture) updating... render calls own stuff (too) */
 void ED_image_update_frame(const struct Main *mainp, int cfra);
 
-void ED_image_draw_info(struct ARegion *ar, int color_manage, int channels, int x, int y,
+void ED_image_draw_info(struct Scene *scene, struct ARegion *ar, int color_manage, int channels, int x, int y,
                         const unsigned char cp[4], const float fp[4], int *zp, float *zpf);
 
 #endif /* __ED_IMAGE_H__ */

Modified: branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c	2012-08-27 13:40:19 UTC (rev 50249)
+++ branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c	2012-08-27 15:23:14 UTC (rev 50250)
@@ -124,7 +124,7 @@
 }
 
 /* used by node view too */
-void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int y,
+void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int channels, int x, int y,
                         const unsigned char cp[4], const float fp[4], int *zp, float *zpf)
 {
 	char str[256];
@@ -221,6 +221,18 @@
 			BLF_draw_ascii(blf_mono_font, str, sizeof(str));
 			dx += BLF_width(blf_mono_font, str);
 		}
+
+		/* OCIO_TODO: make it fit better to overall color interaction */
+		if (fp && channels == 4) {
+			float pixel[4];
+
+			IMB_display_buffer_pixel(pixel, fp,  &scene->view_settings, &scene->display_settings);
+
+			BLI_snprintf(str, sizeof(str), "  |  CM  R:%-.4f  G:%-.4f  B:%-.4f", pixel[0], pixel[1], pixel[2]);
+			BLF_position(blf_mono_font, dx, 6, 0);
+			BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+			dx += BLF_width(blf_mono_font, str);
+		}
 	}
 	
 	/* color rectangle */

Modified: branches/soc-2011-tomato/source/blender/editors/space_image/image_ops.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_image/image_ops.c	2012-08-27 13:40:19 UTC (rev 50249)
+++ branches/soc-2011-tomato/source/blender/editors/space_image/image_ops.c	2012-08-27 15:23:14 UTC (rev 50250)
@@ -1987,12 +1987,14 @@
 	int draw;
 } ImageSampleInfo;
 
-static void image_sample_draw(const bContext *UNUSED(C), ARegion *ar, void *arg_info)
+static void image_sample_draw(const bContext *C, ARegion *ar, void *arg_info)
 {
 	ImageSampleInfo *info = arg_info;
 	if (info->draw) {
+		Scene *scene = CTX_data_scene(C);
+
 		/* no color management needed for images (color_manage=0) */
-		ED_image_draw_info(ar, 0, info->channels, info->x, info->y, info->colp, info->colfp, info->zp, info->zfp);
+		ED_image_draw_info(scene, ar, 0, info->channels, info->x, info->y, info->colp, info->colfp, info->zp, info->zfp);
 	}
 }
 

Modified: branches/soc-2011-tomato/source/blender/editors/space_node/node_view.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_node/node_view.c	2012-08-27 13:40:19 UTC (rev 50249)
+++ branches/soc-2011-tomato/source/blender/editors/space_node/node_view.c	2012-08-27 15:23:14 UTC (rev 50250)
@@ -341,7 +341,7 @@
 	ImageSampleInfo *info = arg_info;
 
 	if (info->draw) {
-		ED_image_draw_info(ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
+		ED_image_draw_info(scene, ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
 		                   info->x, info->y, info->col, info->colf,
 		                   NULL, NULL /* zbuf - unused for nodes */
 		                   );

Modified: branches/soc-2011-tomato/source/blender/editors/space_sequencer/sequencer_view.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_sequencer/sequencer_view.c	2012-08-27 13:40:19 UTC (rev 50249)
+++ branches/soc-2011-tomato/source/blender/editors/space_sequencer/sequencer_view.c	2012-08-27 15:23:14 UTC (rev 50250)
@@ -78,7 +78,7 @@
 	ImageSampleInfo *info = arg_info;
 
 	if (info->draw) {
-		ED_image_draw_info(ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
+		ED_image_draw_info(scene, ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
 		                   info->x, info->y, info->col, info->colf, NULL, NULL);
 	}
 }

Modified: branches/soc-2011-tomato/source/blender/imbuf/IMB_colormanagement.h
===================================================================
--- branches/soc-2011-tomato/source/blender/imbuf/IMB_colormanagement.h	2012-08-27 13:40:19 UTC (rev 50249)
+++ branches/soc-2011-tomato/source/blender/imbuf/IMB_colormanagement.h	2012-08-27 15:23:14 UTC (rev 50250)
@@ -71,6 +71,9 @@
                                           const struct ColorManagedDisplaySettings *display_settings, void **cache_handle);
 unsigned char *IMB_display_buffer_acquire_ctx(const struct bContext *C, struct ImBuf *ibuf, void **cache_handle);
 
+void IMB_display_buffer_pixel(float result[4], const float pixel[4],  const struct ColorManagedViewSettings *view_settings,
+                              const struct ColorManagedDisplaySettings *display_settings);
+
 void IMB_display_buffer_to_imbuf_rect(struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings,
                                       const struct ColorManagedDisplaySettings *display_settings);
 

Modified: branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c
===================================================================
--- branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c	2012-08-27 13:40:19 UTC (rev 50249)
+++ branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c	2012-08-27 15:23:14 UTC (rev 50250)
@@ -1315,6 +1315,23 @@
 	return IMB_display_buffer_acquire(ibuf, view_settings, display_settings, cache_handle);
 }
 
+void IMB_display_buffer_pixel(float result[4], const float pixel[4],  const ColorManagedViewSettings *view_settings,
+                              const ColorManagedDisplaySettings *display_settings)
+{
+	ConstProcessorRcPtr *processor;
+	const float gamma = view_settings->gamma;
+	const float exposure = view_settings->exposure;
+	const char *view_transform = view_settings->view_transform;
+	const char *display = display_settings->display_device;
+
+	copy_v4_v4(result, pixel);
+
+	processor = create_display_buffer_processor(view_transform, display, exposure, gamma);
+
+	if (processor)
+		OCIO_processorApplyRGBA(processor, result);
+}
+
 void IMB_display_buffer_to_imbuf_rect(ImBuf *ibuf, const ColorManagedViewSettings *view_settings,
                                       const ColorManagedDisplaySettings *display_settings)
 {




More information about the Bf-blender-cvs mailing list