summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-07-16 14:14:52 -0400
committerJune McEnroe <june@causal.agency>2018-07-16 14:14:52 -0400
commitd5262930a4c91d1a4f021dc69056194818bc721d (patch)
tree1a59bd2839fcde52fdda97ec60b7cfe99af405a7
parentmalloc deflate buffer in glitch (diff)
downloadsrc-d5262930a4c91d1a4f021dc69056194818bc721d.tar.gz
src-d5262930a4c91d1a4f021dc69056194818bc721d.zip
Add -m option to glitch
Diffstat (limited to '')
-rw-r--r--bin/README1
-rw-r--r--bin/glitch.c15
2 files changed, 15 insertions, 1 deletions
diff --git a/bin/README b/bin/README
index 0ea3970a..3e53eba2 100644
--- a/bin/README
+++ b/bin/README
@@ -76,6 +76,7 @@ PNG glitcher based on pngo.
     -r         reconstruct when filtering
     -d LIST    declare pattern of comma-separated filters
     -a LIST    apply pattern of comma-separated filters
+    -m         mirror scanlines after filtering
 
                                   hnel
 
diff --git a/bin/glitch.c b/bin/glitch.c
index 6a3967f7..9e2f2e35 100644
--- a/bin/glitch.c
+++ b/bin/glitch.c
@@ -276,6 +276,7 @@ static struct {
 	uint8_t applyFilter;
 	enum Filter declareFilters[255];
 	enum Filter applyFilters[255];
+	bool mirror;
 } options;
 
 struct Bytes {
@@ -396,6 +397,16 @@ static void filterData(void) {
 	}
 }
 
+static void mirror(void) {
+	for (uint32_t y = 0; y < header.height; ++y) {
+		for (size_t i = 0, j = lineSize() - 1; i < j; ++i, --j) {
+			uint8_t t = lines[y]->data[i];
+			lines[y]->data[i] = lines[y]->data[j];
+			lines[y]->data[j] = t;
+		}
+	}
+}
+
 static void glitch(const char *inPath, const char *outPath) {
 	if (inPath) {
 		path = inPath;
@@ -415,6 +426,7 @@ static void glitch(const char *inPath, const char *outPath) {
 	scanlines();
 	reconData();
 	filterData();
+	if (options.mirror) mirror();
 	free(lines);
 
 	if (outPath) {
@@ -462,7 +474,7 @@ int main(int argc, char *argv[]) {
 	char *output = NULL;
 
 	int opt;
-	while (0 < (opt = getopt(argc, argv, "a:cd:fo:pr"))) {
+	while (0 < (opt = getopt(argc, argv, "a:cd:fmo:pr"))) {
 		switch (opt) {
 			break; case 'a':
 				options.applyFilter = parseFilters(options.applyFilters, optarg);
@@ -470,6 +482,7 @@ int main(int argc, char *argv[]) {
 			break; case 'd':
 				options.declareFilter = parseFilters(options.declareFilters, optarg);
 			break; case 'f': options.filt = true;
+			break; case 'm': options.mirror = true;
 			break; case 'o': output = optarg;
 			break; case 'p': options.brokenPaeth = true;
 			break; case 'r': options.recon = true;
7cdedf4f31a8d&follow=1'>Make sure new cap is actually larger than new lengthJune McEnroe 2022-02-20Remove unused mbs.len field from struct EditJune McEnroe 2022-02-19Remove unneeded includes in ui.cJune McEnroe 2022-02-19Reimplement tab completeJune McEnroe 2022-02-19Handle errors from editFn, etc.June McEnroe 2022-02-19Reimplement text macrosJune McEnroe 2022-02-19Factor out input handling to input.cJune McEnroe 2022-02-19Factor out window management to window.cJune McEnroe 2022-02-19Enable -Wmissing-prototypesJune McEnroe In other words, warn when a function is missing static. I don't see why this isn't in -Wextra. 2022-02-19Fix edit.[ch] license notice additional permissionsJune McEnroe 2022-02-19Run line editing testsJune McEnroe I know, it feels wrong. 2022-02-18Implement new line editing "library"June McEnroe Losing tab complete and text macros, for now. This new implementation works on an instance of a struct and does not interact with the rest of catgirl, making it possible to copy into another project. Unlike existing line editing libraries, this one is entirely abstract and can be rendered externally. My goal with this library is to be able to implement vi mode. Since it operates on struct instances rather than globals, it might also be possible to give catgirl separate line editing buffers for each window, which would be a nice UX improvement. 2022-02-18Simplify cursor positioning in inputJune McEnroe Do some extra work by adding the portion before the cursor to the input window twice, but simplify the interaction with the split point. This fixes the awkward behaviour when moving the cursor across colour codes where the code would be partially interpreted up to the cursor. 2022-02-18Fix M-f orderingJune McEnroe 2022-02-12Move sandman build to scripts/MakefileJune McEnroe 2022-02-12Use compat_readpassphrase.c on LinuxJune McEnroe 2022-02-12Copy RPP defines from oconfigureJune McEnroe