aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorWojciech Kosior <kwojtus@protonmail.com>2020-09-01 10:54:59 +0200
committerWojciech Kosior <kwojtus@protonmail.com>2020-09-01 11:04:22 +0200
commitee1f6c47e1eff920068f4bceaf604f9535a2e8a9 (patch)
tree580eb001a72601d254bb29cc348a529490f84808 /tools
parentcd02ddff8886aa1db29f80d3cc5cf99a349d8258 (diff)
downloadAGH-engineering-thesis-ee1f6c47e1eff920068f4bceaf604f9535a2e8a9.tar.gz
AGH-engineering-thesis-ee1f6c47e1eff920068f4bceaf604f9535a2e8a9.zip
start anew
Diffstat (limited to 'tools')
-rw-r--r--tools/VGAdump2ppm.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/tools/VGAdump2ppm.c b/tools/VGAdump2ppm.c
new file mode 100644
index 0000000..0c91891
--- /dev/null
+++ b/tools/VGAdump2ppm.c
@@ -0,0 +1,45 @@
+#include <stdio.h>
+#include <stdint.h>
+
+int main(int argc, char **argv)
+{
+ uint8_t color_value = 0;
+ uint8_t bits_read = 0;
+ uint8_t channels_read = 0;
+ int pixels_processed = 0;
+ int input;
+
+ /* http://netpbm.sourceforge.net/doc/ppm.html */
+ puts("P3");
+ puts("640 480");
+ puts("7");
+
+ while (1) {
+ input = getchar();
+
+ if (input == EOF)
+ break;
+
+ if (input != '1' && input != '0')
+ continue;
+
+ if (input == '1')
+ color_value |= 1 << (2 - bits_read);
+
+ if (++bits_read == 3) {
+ printf(" %d", color_value);
+
+ color_value = 0;
+ bits_read = 0;
+
+ if (++channels_read == 3) {
+ channels_read = 0;
+
+ putchar(++pixels_processed % 8 == 0 ?
+ '\n' : ' ');
+ }
+ }
+ }
+
+ return 0;
+}