summary refs log tree commit diff
path: root/bin/gfxx.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bin/gfxx.c43
1 files changed, 16 insertions, 27 deletions
diff --git a/bin/gfxx.c b/bin/gfxx.c
index d680fda6..9a6a6c84 100644
--- a/bin/gfxx.c
+++ b/bin/gfxx.c
@@ -314,19 +314,15 @@ static void pngUint32(uint32_t data) {
 static void pngDump(uint32_t *src, size_t srcWidth, size_t srcHeight) {
     int error;
 
-    size_t scanline = 1 + (space == COLOR_GRAYSCALE ? 1 : 3) * srcWidth;
+    size_t scanline = 1 + 3 * srcWidth;
     uint8_t filt[scanline * srcHeight];
     for (size_t y = 0; y < srcHeight; ++y) {
         filt[y * scanline] = 0; // None
         for (size_t x = 0; x < srcWidth; ++x) {
-            if (space == COLOR_GRAYSCALE) {
-                filt[y * scanline + 1 + x] = src[y * srcWidth + x];
-            } else {
-                uint8_t *filtPixel = &filt[y * scanline + 1 + 3 * x];
-                filtPixel[0] = src[y * srcWidth + x] >> 16;
-                filtPixel[1] = src[y * srcWidth + x] >> 8;
-                filtPixel[2] = src[y * srcWidth + x];
-            }
+            uint8_t *filtPixel = &filt[y * scanline + 1 + 3 * x];
+            filtPixel[0] = src[y * srcWidth + x] >> 16;
+            filtPixel[1] = src[y * srcWidth + x] >> 8;
+            filtPixel[2] = src[y * srcWidth + x];
         }
     }
 
@@ -340,31 +336,24 @@ static void pngDump(uint32_t *src, size_t srcWidth, size_t srcHeight) {
     if (!png) { warn("%s", pngPath); return; }
     printf("%s\n", pngPath);
 
-    uint8_t signature[] = { 0x89, 'P', 'N', 'G', '\r', '\n', 0x1A, '\n' };
-    uint8_t header[] = { 8, (space == COLOR_GRAYSCALE ? 0 : 2), 0, 0, 0 };
-    char software[] = "Software";
+    const uint8_t SIGNATURE[] = { 0x89, 'P', 'N', 'G', '\r', '\n', 0x1A, '\n' };
+    const uint8_t HEADER[] = { 8, 2, 0, 0, 0 }; // 8-bit truecolor
+    const char SOFTWARE[] = "Software";
     formatOptions();
 
-    pngWrite(signature, sizeof(signature));
-    PNG_CHUNK("IHDR", 4 + 4 + sizeof(header)) {
+    pngWrite(SIGNATURE, sizeof(SIGNATURE));
+    PNG_CHUNK("IHDR", 4 + 4 + sizeof(HEADER)) {
         pngUint32(srcWidth);
         pngUint32(srcHeight);
-        pngWrite(header, sizeof(header));
+        pngWrite(HEADER, sizeof(HEADER));
     }
-    PNG_CHUNK("tEXt", sizeof(software) + strlen(options)) {
-        pngWrite(software, sizeof(software));
+    PNG_CHUNK("tEXt", sizeof(SOFTWARE) + strlen(options)) {
+        pngWrite(SOFTWARE, sizeof(SOFTWARE));
         pngWrite(options, strlen(options));
     }
-    if (space == COLOR_GRAYSCALE) {
-        PNG_CHUNK("sBIT", 1) {
-            uint8_t sbit = BITS_COLOR;
-            pngWrite(&sbit, 1);
-        }
-    } else {
-        PNG_CHUNK("sBIT", 3) {
-            uint8_t sbit[] = { MAX(bits[R], 1), MAX(bits[G], 1), MAX(bits[B], 1) };
-            pngWrite(sbit, sizeof(sbit));
-        }
+    PNG_CHUNK("sBIT", 3) {
+        uint8_t sbit[] = { MAX(bits[R], 1), MAX(bits[G], 1), MAX(bits[B], 1) };
+        pngWrite(sbit, sizeof(sbit));
     }
     PNG_CHUNK("IDAT", dataSize) {
         pngWrite(data, dataSize);
span title='2019-02-22 17:44:39 -0500'>2019-02-22Remove topic TODOJune McEnroe I played around with it and it doesn't look right unless there is only one channel listed in the status. 2019-02-22Add /znc commandJune McEnroe Only because ZNC tells you to use it and expects it to work. 2019-02-22Update status line after scrolling and term eventsJune McEnroe 2019-02-22Reorganize input.cJune McEnroe 2019-02-22Fix name of <raw> window in man pageJune McEnroe 2019-02-22Rename global tags with angle bracketsJune McEnroe 2019-02-22Show status window while connectingJune McEnroe 2019-02-22Reorganize UI code for the umpteenth timeJune McEnroe It's actually in a good state now, I think. 2019-02-21Replace "view" with "window"June McEnroe I think originally I didn't want to use the same word as curses WINDOW but it's really much clearer for the user if they're just called windows. UI code probably needs yet another rewrite though. Still feels messy. 2019-02-21Remove ROT13June McEnroe It's just not convenient when it can only do the whole line... 2019-02-21Clean up man pageJune McEnroe 2019-01-26Draw UI before connectingJune McEnroe Otherwise the "Traveling" message isn't visible while connecting. 2019-01-25Avoid unused variable warnings with getyxJune McEnroe 2019-01-25Add GNU/Linux build instructionsJune McEnroe