summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
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 3d58fa33..f62ee1fc 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;