From 76a446debab1d74cccbe750f4e94c5bc0a3efefb Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 31 Aug 2025 09:54:29 +0200 Subject: [PATCH] Fix: Wrong color space for gizmo, fluid grid line and stamp colors Mark these as sRGB, as they already were or should be interpreted this way. Pull Request: https://projects.blender.org/blender/blender/pulls/145755 --- source/blender/blenkernel/intern/image.cc | 40 ++++++++++--------- source/blender/imbuf/intern/rectop.cc | 1 - source/blender/makesrna/intern/rna_fluid.cc | 2 +- source/blender/makesrna/intern/rna_scene.cc | 4 +- .../blender/makesrna/intern/rna_wm_gizmo.cc | 4 +- 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index a17abb09285..9d2bbb90f99 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -2057,6 +2057,7 @@ void BKE_image_stamp_buf(Scene *scene, ibuf->x, ibuf->y, ibuf->byte_buffer.colorspace); + /* No conversion to scene linear needed, #BLF_buffer_col accepts sRGB. */ BLF_buffer_col(mono, scene->r.fg_stamp); pad = BLF_width_max(mono); @@ -2067,13 +2068,18 @@ void BKE_image_stamp_buf(Scene *scene, x = 0; y = ibuf->y; + /* Background needs to be converted to scene linear. */ + float bg_stamp[4]; + IMB_colormanagement_srgb_to_scene_linear_v3(bg_stamp, scene->r.bg_stamp); + bg_stamp[3] = scene->r.bg_stamp[3]; + if (TEXT_SIZE_CHECK(stamp_data.file, w, h)) { /* Top left corner */ y -= h; /* also a little of space to the background. */ IMB_rectfill_area(ibuf, - scene->r.bg_stamp, + bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, @@ -2093,7 +2099,7 @@ void BKE_image_stamp_buf(Scene *scene, /* and space for background. */ IMB_rectfill_area( - ibuf, scene->r.bg_stamp, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); + ibuf, bg_stamp, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.date, sizeof(stamp_data.date)); @@ -2108,7 +2114,7 @@ void BKE_image_stamp_buf(Scene *scene, /* and space for background. */ IMB_rectfill_area( - ibuf, scene->r.bg_stamp, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); + ibuf, bg_stamp, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.rendertime, sizeof(stamp_data.rendertime)); @@ -2123,7 +2129,7 @@ void BKE_image_stamp_buf(Scene *scene, /* and space for background. */ IMB_rectfill_area( - ibuf, scene->r.bg_stamp, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); + ibuf, bg_stamp, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.memory, sizeof(stamp_data.memory)); @@ -2138,7 +2144,7 @@ void BKE_image_stamp_buf(Scene *scene, /* and space for background. */ IMB_rectfill_area( - ibuf, scene->r.bg_stamp, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); + ibuf, bg_stamp, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.hostname, sizeof(stamp_data.hostname)); @@ -2154,7 +2160,7 @@ void BKE_image_stamp_buf(Scene *scene, /* and space for background. */ IMB_rectfill_area( - ibuf, scene->r.bg_stamp, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); + ibuf, bg_stamp, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs + (h - h_fixed), 0.0); BLF_draw_buffer(mono, stamp_data.note, sizeof(stamp_data.note)); @@ -2169,7 +2175,7 @@ void BKE_image_stamp_buf(Scene *scene, /* extra space for background. */ IMB_rectfill_area(ibuf, - scene->r.bg_stamp, + bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, @@ -2187,12 +2193,8 @@ void BKE_image_stamp_buf(Scene *scene, if (TEXT_SIZE_CHECK(stamp_data.time, w, h)) { /* extra space for background */ - IMB_rectfill_area(ibuf, - scene->r.bg_stamp, - x - BUFF_MARGIN_X, - y, - x + w + BUFF_MARGIN_X, - y + h + BUFF_MARGIN_Y); + IMB_rectfill_area( + ibuf, bg_stamp, x - BUFF_MARGIN_X, y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); /* and pad the text. */ BLF_position(mono, x, y + y_ofs, 0.0); @@ -2206,7 +2208,7 @@ void BKE_image_stamp_buf(Scene *scene, /* extra space for background. */ IMB_rectfill_area(ibuf, - scene->r.bg_stamp, + bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, @@ -2224,7 +2226,7 @@ void BKE_image_stamp_buf(Scene *scene, /* extra space for background. */ IMB_rectfill_area(ibuf, - scene->r.bg_stamp, + bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, @@ -2242,7 +2244,7 @@ void BKE_image_stamp_buf(Scene *scene, /* extra space for background. */ IMB_rectfill_area(ibuf, - scene->r.bg_stamp, + bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, @@ -2258,7 +2260,7 @@ void BKE_image_stamp_buf(Scene *scene, /* extra space for background. */ IMB_rectfill_area(ibuf, - scene->r.bg_stamp, + bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, @@ -2274,7 +2276,7 @@ void BKE_image_stamp_buf(Scene *scene, /* extra space for background. */ IMB_rectfill_area(ibuf, - scene->r.bg_stamp, + bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, @@ -2293,7 +2295,7 @@ void BKE_image_stamp_buf(Scene *scene, /* extra space for background. */ IMB_rectfill_area(ibuf, - scene->r.bg_stamp, + bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, diff --git a/source/blender/imbuf/intern/rectop.cc b/source/blender/imbuf/intern/rectop.cc index c3da06ff5f3..adc3a007e46 100644 --- a/source/blender/imbuf/intern/rectop.cc +++ b/source/blender/imbuf/intern/rectop.cc @@ -10,7 +10,6 @@ #include #include "BLI_math_base.h" -#include "BLI_math_color.h" #include "BLI_math_color_blend.h" #include "BLI_math_vector.h" #include "BLI_rect.h" diff --git a/source/blender/makesrna/intern/rna_fluid.cc b/source/blender/makesrna/intern/rna_fluid.cc index f8a59e3aecb..c14efb65df3 100644 --- a/source/blender/makesrna/intern/rna_fluid.cc +++ b/source/blender/makesrna/intern/rna_fluid.cc @@ -2641,7 +2641,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Upper Bound", "Upper bound of the highlighting range"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, nullptr); - prop = RNA_def_property(srna, "gridlines_range_color", PROP_FLOAT, PROP_COLOR); + prop = RNA_def_property(srna, "gridlines_range_color", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, nullptr, "gridlines_range_color"); RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Color", "Color used to highlight the range"); diff --git a/source/blender/makesrna/intern/rna_scene.cc b/source/blender/makesrna/intern/rna_scene.cc index 5dc304ae958..279a96e0674 100644 --- a/source/blender/makesrna/intern/rna_scene.cc +++ b/source/blender/makesrna/intern/rna_scene.cc @@ -7370,14 +7370,14 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Font Size", "Size of the font used when rendering stamp text"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr); - prop = RNA_def_property(srna, "stamp_foreground", PROP_FLOAT, PROP_COLOR); + prop = RNA_def_property(srna, "stamp_foreground", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, nullptr, "fg_stamp"); RNA_def_property_array(prop, 4); RNA_def_property_range(prop, 0.0, 1.0); RNA_def_property_ui_text(prop, "Text Color", "Color to use for stamp text"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr); - prop = RNA_def_property(srna, "stamp_background", PROP_FLOAT, PROP_COLOR); + prop = RNA_def_property(srna, "stamp_background", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, nullptr, "bg_stamp"); RNA_def_property_array(prop, 4); RNA_def_property_range(prop, 0.0, 1.0); diff --git a/source/blender/makesrna/intern/rna_wm_gizmo.cc b/source/blender/makesrna/intern/rna_wm_gizmo.cc index de35152ad01..5b513e29264 100644 --- a/source/blender/makesrna/intern/rna_wm_gizmo.cc +++ b/source/blender/makesrna/intern/rna_wm_gizmo.cc @@ -1140,7 +1140,7 @@ static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_ui_text(prop, "", "Gizmo group this gizmo is a member of"); /* Color & Alpha */ - prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); + prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_Gizmo_color_get", "rna_Gizmo_color_set", nullptr); @@ -1151,7 +1151,7 @@ static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw"); /* Color & Alpha (highlight) */ - prop = RNA_def_property(srna, "color_highlight", PROP_FLOAT, PROP_COLOR); + prop = RNA_def_property(srna, "color_highlight", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_Gizmo_color_hi_get", "rna_Gizmo_color_hi_set", nullptr);