Skip to content

Add RGB% mode to Global Color Picker (#18269) #18855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/libs/colorpicker.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ DT_MODULE(1);
typedef enum dt_lib_colorpicker_model_t
{
DT_LIB_COLORPICKER_MODEL_RGB = 0,
DT_LIB_COLORPICKER_MODEL_RGB_PERCENT,
DT_LIB_COLORPICKER_MODEL_LAB,
DT_LIB_COLORPICKER_MODEL_LCH,
DT_LIB_COLORPICKER_MODEL_HSL,
Expand All @@ -48,7 +49,7 @@ typedef enum dt_lib_colorpicker_model_t
} dt_lib_colorpicker_model_t;

const gchar *dt_lib_colorpicker_model_names[]
= { N_("RGB"), N_("Lab"), N_("LCh"), N_("HSL"), N_("HSV"), N_("Hex"), N_("none"), NULL };
= { N_("RGB"), N_("RGB%"), N_("Lab"), N_("LCh"), N_("HSL"), N_("HSV"), N_("Hex"), N_("none"), NULL };
const gchar *dt_lib_colorpicker_statistic_names[]
= { N_("mean"), N_("min"), N_("max"), NULL };

Expand Down Expand Up @@ -208,7 +209,12 @@ static void _update_sample_label(dt_lib_module_t *self,
snprintf(text, sizeof(text), "%6d %6d %6d",
sample->label_rgb[0], sample->label_rgb[1], sample->label_rgb[2]);
break;

case DT_LIB_COLORPICKER_MODEL_RGB_PERCENT:
snprintf(text, sizeof(text), "%6.1f%% %6.1f%% %6.1f%%",
(sample->scope[statistic][0] * 100.f),
(sample->scope[statistic][1] * 100.f),
(sample->scope[statistic][2] * 100.f));
break;
case DT_LIB_COLORPICKER_MODEL_LAB:
snprintf(text, sizeof(text), "%6.02f %6.02f %6.02f",
CLAMP(sample->lab[statistic][0], .0f, 100.0f),
Expand Down
Loading