aboutsummaryrefslogtreecommitdiffstats
path: root/commands.c
diff options
context:
space:
mode:
authorBerke Kocaoğlu <kberke@metu.edu.tr>2022-12-22 12:21:40 +0100
committerNRK <nrk@disroot.org>2022-12-22 12:21:40 +0100
commit95bc9b463b87236d30d86626e1052e6979d6510f (patch)
treec3de438755c7ed7ff8e6cfdf5dae4359f28c364e /commands.c
parent9cb9a54944e8ad9a42b3113286cb51bceae4b2d0 (diff)
downloadnsxiv-95bc9b463b87236d30d86626e1052e6979d6510f.tar.zst
add brightness and contrast (#396)
* Imlib2 supports modifying gamma, brightness and contrast directly while sxiv only supports gamma. Makes sense to extend it to brightness and contrast as well. * Since color corrections need to be aware of each other, they have been refactored into one centralized function. * This also makes the code more hackable as it makes it easier to add more color correction functions without them interfering with each other. Co-authored-by: 0ion9 <finticemo@gmail.com> Co-authored-by: NRK <nrk@disroot.org> Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/396 Reviewed-by: NRK <nrk@disroot.org> Reviewed-by: TAAPArthur <taaparthur@noreply.codeberg.org> Co-authored-by: Berke Kocaoğlu <kberke@metu.edu.tr> Co-committed-by: Berke Kocaoğlu <kberke@metu.edu.tr>
Diffstat (limited to 'commands.c')
-rw-r--r--commands.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/commands.c b/commands.c
index 3cc921c..1ba0363 100644
--- a/commands.c
+++ b/commands.c
@@ -222,15 +222,28 @@ bool cg_navigate_marked(arg_t n)
return navigate_to(new);
}
-bool cg_change_gamma(arg_t d)
+static bool change_color_modifier(arg_t d, int *target)
{
- if (img_change_gamma(&img, d * (prefix > 0 ? prefix : 1))) {
- if (mode == MODE_THUMB)
- tns.dirty = true;
- return true;
- } else {
+ if (!img_change_color_modifier(&img, d * (prefix > 0 ? prefix : 1), target))
return false;
- }
+ if (mode == MODE_THUMB)
+ tns.dirty = true;
+ return true;
+}
+
+bool cg_change_gamma(arg_t d)
+{
+ return change_color_modifier(d, &img.gamma);
+}
+
+bool cg_change_brightness(arg_t d)
+{
+ return change_color_modifier(d, &img.brightness);
+}
+
+bool cg_change_contrast(arg_t d)
+{
+ return change_color_modifier(d, &img.contrast);
}
bool ci_navigate(arg_t n)