Color Management, Stage 2: Switch color pipeline to use OpenColorIO
[blender.git] / source / blender / editors / space_sequencer / sequencer_view.c
index f5a13e4efb77e29c683afdfdeaad1fcd4c02e515..3c3489115a458b1da63476b85ae55df0158bdc75 100644 (file)
@@ -49,6 +49,7 @@
 
 #include "IMB_imbuf.h"
 #include "IMB_imbuf_types.h"
+#include "IMB_colormanagement.h"
 
 #include "UI_view2d.h"
 
@@ -70,6 +71,7 @@ typedef struct ImageSampleInfo {
        float *colfp;
 
        int draw;
+int color_manage;
 } ImageSampleInfo;
 
 static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
@@ -78,8 +80,8 @@ 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,
-                                  info->x, info->y, info->col, info->colf, NULL, NULL);
+               ED_image_draw_info(scene, ar, info->color_manage, FALSE, info->channels,
+                                  info->x, info->y, info->colp, info->colfp, NULL, NULL);
        }
 }
 
@@ -131,6 +133,8 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
                        info->colf[2] = (float)cp[2] / 255.0f;
                        info->colf[3] = (float)cp[3] / 255.0f;
                        info->colfp = info->colf;
+
+                       info->color_manage = FALSE;
                }
                if (ibuf->rect_float) {
                        fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
@@ -140,6 +144,11 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
                        info->colf[2] = fp[2];
                        info->colf[3] = fp[3];
                        info->colfp = info->colf;
+
+                       /* sequencer's image buffers are in non-linear space, need to make them linear */
+                       BKE_sequencer_pixel_from_sequencer_space_v4(scene, info->colf);
+
+                       info->color_manage = TRUE;
                }
        }
        else {