From fde8b7160dbc7b7e48b256c566705ba9a5080951 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Fri, 4 Oct 2024 00:28:57 +0200 Subject: [PATCH] restore gamma correction --- display.c | 6 ------ image.c | 6 ++++++ image.h | 2 ++ ndisplay.c | 27 +++++++++++++++------------ 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/display.c b/display.c index cc03fbc..5c7c82f 100644 --- a/display.c +++ b/display.c @@ -4,7 +4,6 @@ /* doslnk: color.o debug.o image.o pnm.o -lm */ /* winlnk: color.o debug.o image.o pnm.o -lm */ -#include #include #include @@ -37,11 +36,6 @@ int usage (int ret) return ret; } -float correction (float value, float factor) -{ - return powf (value, 1. / factor); -} - /* main function */ int main (int argc, char *argv[]) { diff --git a/image.c b/image.c index 99b6a24..7234084 100644 --- a/image.c +++ b/image.c @@ -1,3 +1,4 @@ +#include #include #include "image.h" @@ -34,4 +35,9 @@ int contain (char *str, char c) return 1; } +float correction (float value, float factor) +{ + return powf (value, 1. / factor); +} + /* vim: set ts=4 sw=4 et: */ diff --git a/image.h b/image.h index e6542aa..155bab5 100644 --- a/image.h +++ b/image.h @@ -18,4 +18,6 @@ void freeimage (image_t *image); int contain (char *str, char c); +float correction (float value, float factor); + #endif /* __IMAGE_H__ */ diff --git a/ndisplay.c b/ndisplay.c index 6b42957..b45053d 100644 --- a/ndisplay.c +++ b/ndisplay.c @@ -1,8 +1,8 @@ /* depend: */ /* cflags: */ -/* linker: color.o debug.o image.o pnm.o -lncursesw */ -/* doslnk: color.o debug.o image.o pnm.o -lpdc~2 */ -/* winlnk: color.o debug.o image.o pnm.o -lpdcursesw */ +/* linker: color.o debug.o image.o pnm.o -lncursesw -lm */ +/* doslnk: color.o debug.o image.o pnm.o -lpdc~2 -lm */ +/* winlnk: color.o debug.o image.o pnm.o -lpdcursesw -lm */ #include #include @@ -152,26 +152,29 @@ int main (int argc, char *argv[]) int width = min (image->width - xcursor, COLS / mode); int height = min (image->height - ycursor, LINES); + VERBOSE (DEBUG, FILE *fd = fopen ("my.log", "a"); fprintf (fd, "(%d, %d)\n", width, height); fclose (fd)); int x, y; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { int ind = (x + xcursor) + image->width * (y + ycursor); - color_t *color = findcolor (image->red[ind], image->green[ind], image->blue[ind], colormap); - //color_t *color = findcolor (correction (image->red[ind], gf[0]), correction (image->green[ind], gf[1]), correction (image->blue[ind], gf[2]), colormap); + color_t *color = findcolor (correction (image->red[ind], gf[0]), + correction (image->green[ind], gf[1]), + correction (image->blue[ind], gf[2]), colormap); attron (COLOR_PAIR (color->code)); - + move (y, x * mode); - cchar_t tmp; - wchar_t tmp_wchar[2] = {0}; - tmp_wchar[0] = (wchar_t) ' '; - setcchar (&tmp, tmp_wchar, A_NORMAL, 0, NULL); - add_wch (&tmp); + cchar_t cchar; + wchar_t wchar[2] = {0}; + wchar[0] = (wchar_t) ' '; + setcchar (&cchar, wchar, A_NORMAL, 0, NULL); + add_wch (&cchar); if (mode == 2) { move (y, x * mode + 1); - add_wch (&tmp); + add_wch (&cchar); } } + refresh (); } refresh (); attron (COLOR_PAIR (0)); -- 2.30.2