Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-03-18 15:34:05 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-03-18 15:34:05 +0400
commitb19155e76cca879724f7deae2cfd71d19f953229 (patch)
treefd9f377b847c3e299617ab6ed28609653e5cd72d /source/blender/editors/space_image
parent4c1d80bf86d112deef528d3737230452e3616839 (diff)
Fix #34672: Image sampling line didn't use color management for byte buffers
This makes it so sample line (for all image editor, sequencer and compositor) displaying managed color for byte buffers as well. It was simply not implemented before.
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r--source/blender/editors/space_image/image_draw.c39
-rw-r--r--source/blender/editors/space_image/image_ops.c10
2 files changed, 24 insertions, 25 deletions
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index e69ce56c9d9..f27a99ac44b 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -162,7 +162,7 @@ static void draw_render_info(Scene *scene, Image *ima, ARegion *ar, float zoomx,
/* used by node view too */
void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_default_view, int channels, int x, int y,
- const unsigned char cp[4], const float fp[4], int *zp, float *zpf)
+ const unsigned char cp[4], const float fp[4], const float linearcol[4], int *zp, float *zpf)
{
char str[256];
float dx = 6;
@@ -258,15 +258,23 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
dx += BLF_width(blf_mono_font, str);
}
- if (color_manage && channels == 4) {
- float pixel[4];
+ if (color_manage) {
+ float rgba[4];
+
+ copy_v3_v3(rgba, linearcol);
+ if (channels == 3)
+ rgba[3] = 1.0f;
+ else
+ rgba[3] = linearcol[3];
+
+ (void)color_manage;
if (use_default_view)
- IMB_colormanagement_pixel_to_display_space_v4(pixel, fp, NULL, &scene->display_settings);
+ IMB_colormanagement_pixel_to_display_space_v4(rgba, rgba, NULL, &scene->display_settings);
else
- IMB_colormanagement_pixel_to_display_space_v4(pixel, fp, &scene->view_settings, &scene->display_settings);
+ IMB_colormanagement_pixel_to_display_space_v4(rgba, rgba, &scene->view_settings, &scene->display_settings);
- BLI_snprintf(str, sizeof(str), " | CM R:%-.4f G:%-.4f B:%-.4f", pixel[0], pixel[1], pixel[2]);
+ BLI_snprintf(str, sizeof(str), " | CM R:%-.4f G:%-.4f B:%-.4f", rgba[0], rgba[1], rgba[2]);
BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str);
@@ -287,26 +295,11 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
col[3] = 1.0f;
}
else if (channels == 3) {
- if (fp) {
- copy_v3_v3(col, fp);
- }
- else if (cp) {
- rgb_uchar_to_float(col, cp);
- }
- else {
- zero_v3(col);
- }
+ copy_v3_v3(col, linearcol);
col[3] = 1.0f;
}
else if (channels == 4) {
- if (fp)
- copy_v4_v4(col, fp);
- else if (cp) {
- rgba_uchar_to_float(col, cp);
- }
- else {
- zero_v4(col);
- }
+ copy_v4_v4(col, linearcol);
}
else {
BLI_assert(0);
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 54230d35312..7c016cdf3bf 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -2079,6 +2079,7 @@ typedef struct ImageSampleInfo {
unsigned char col[4];
float colf[4];
+ float linearcol[4];
int z;
float zf;
@@ -2099,7 +2100,7 @@ static void image_sample_draw(const bContext *C, ARegion *ar, void *arg_info)
Scene *scene = CTX_data_scene(C);
ED_image_draw_info(scene, ar, info->color_manage, info->use_default_view, info->channels,
- info->x, info->y, info->colp, info->colfp, info->zp, info->zfp);
+ info->x, info->y, info->colp, info->colfp, info->linearcol, info->zp, info->zfp);
}
}
@@ -2198,7 +2199,10 @@ static void image_sample_apply(bContext *C, wmOperator *op, const wmEvent *event
info->colf[3] = (float)cp[3] / 255.0f;
info->colfp = info->colf;
- info->color_manage = FALSE;
+ copy_v4_v4(info->linearcol, info->colf);
+ IMB_colormanagement_colorspace_to_scene_linear_v4(info->linearcol, false, ibuf->rect_colorspace);
+
+ info->color_manage = TRUE;
}
if (ibuf->rect_float) {
fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
@@ -2209,6 +2213,8 @@ static void image_sample_apply(bContext *C, wmOperator *op, const wmEvent *event
info->colf[3] = fp[3];
info->colfp = info->colf;
+ copy_v4_v4(info->linearcol, info->colf);
+
info->color_manage = TRUE;
}