Color management: display color managed RGB values in color sample line
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 27 Aug 2012 15:23:14 +0000 (15:23 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 27 Aug 2012 15:23:14 +0000 (15:23 +0000)
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.

source/blender/editors/include/ED_image.h
source/blender/editors/space_image/image_draw.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_node/node_view.c
source/blender/editors/space_sequencer/sequencer_view.c
source/blender/imbuf/IMB_colormanagement.h
source/blender/imbuf/intern/colormanagement.c

index 6f41bef81f45e2dc67023aa93a2f98e72b7e6ace..70fea4a45fbbd43f9886eb713a100f3b4565bae0 100644 (file)
@@ -39,6 +39,7 @@ struct ToolSettings;
 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 @@ int ED_space_image_maskedit_mask_poll(struct bContext *C);
 /* 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__ */
index 5d6ecd6effeab42196046977ef5b61a3633378eb..1fd29c0163d9580c7ebef427b6da78f549d9027f 100644 (file)
@@ -124,7 +124,7 @@ static void draw_render_info(Scene *scene, Image *ima, ARegion *ar)
 }
 
 /* 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 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int
                        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 */
index 43fe45944067bbfcde76e0a231228ea6509e0a53..0b5216a98932b998d287707082aaa3dabfc06bd9 100644 (file)
@@ -1987,12 +1987,14 @@ typedef struct ImageSampleInfo {
        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);
        }
 }
 
index e89e798a6fabbe1532177edc600987b29e32a89a..dfceb832b6579948186ba990997ff6362fc9aebe 100644 (file)
@@ -341,7 +341,7 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
        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 */
                                   );
index fa39003bd553cc5ccf25f74e81be213cd4904c8c..f83a903c358e7b58c10e61ad21c5035a41f35220 100644 (file)
@@ -78,7 +78,7 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
        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);
        }
 }
index 41055e135e3d1cc54a4274155a61c806b17d6b82..551251565dee455216bc488d88b5a8e28abb265f 100644 (file)
@@ -71,6 +71,9 @@ unsigned char *IMB_display_buffer_acquire(struct ImBuf *ibuf, const struct Color
                                           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);
 
index deffe9f49f128f242f63f8b3731d776c4d388440..954b7540c722ccee93289c2e639c8f8eedaeccd3 100644 (file)
@@ -1315,6 +1315,23 @@ unsigned char *IMB_display_buffer_acquire_ctx(const bContext *C, ImBuf *ibuf, vo
        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)
 {