restore gamma correction
authorLaurent Mazet <mazet@softndesign.org>
Thu, 3 Oct 2024 22:28:57 +0000 (00:28 +0200)
committerLaurent Mazet <mazet@softndesign.org>
Thu, 3 Oct 2024 22:28:57 +0000 (00:28 +0200)
display.c
image.c
image.h
ndisplay.c

index cc03fbc07f093bd2ed09bb7e2bc52be7019eadd9..5c7c82f85f37d3ec32fa4103257c162f49c3d464 100644 (file)
--- 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 <math.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -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 99b6a24953e15391afc9ac7ee78b2d6c4fa7b6f4..72340845a1b716ac366aee1f554f59d47b03b75d 100644 (file)
--- a/image.c
+++ b/image.c
@@ -1,3 +1,4 @@
+#include <math.h>
 #include <stdlib.h>
 
 #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 e6542aa9d15468ba692b68eba83eab55dfdad917..155bab5202291f6488189559ebabd0de1d23b916 100644 (file)
--- 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__ */
index 6b42957a4e35e93964f9d92ae1be3da9be34cdfc..b45053dc018805a8b5a8f3ec60c390554002b0c7 100644 (file)
@@ -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 <curses.h>
 #include <stdio.h>
@@ -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));