summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-09-04 23:05:44 -0400
committerJune McEnroe <june@causal.agency>2018-09-04 23:05:44 -0400
commit0f30c2e691ca05d78ca53cae9eaecdc2596c40ed (patch)
treeea23b892c1fc08ac8fdbb1609de052397a2a457f /bin
parentmalloc IDAT chunks in pngo and glitch (diff)
downloadsrc-0f30c2e691ca05d78ca53cae9eaecdc2596c40ed.tar.gz
src-0f30c2e691ca05d78ca53cae9eaecdc2596c40ed.zip
Add -i invert option to glitch
Diffstat (limited to '')
-rw-r--r--bin/glitch.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/bin/glitch.c b/bin/glitch.c
index 60a4ff7c..b8251df7 100644
--- a/bin/glitch.c
+++ b/bin/glitch.c
@@ -278,6 +278,7 @@ static struct {
 	uint8_t applyFilter;
 	enum Filter declareFilters[255];
 	enum Filter applyFilters[255];
+	bool invert;
 	bool mirror;
 } options;
 
@@ -399,6 +400,14 @@ static void filterData(void) {
 	}
 }
 
+static void invert(void) {
+	for (uint32_t y = 0; y < header.height; ++y) {
+		for (size_t i = 0; i < lineSize(); ++i) {
+			lines[y]->data[i] ^= 0xFF;
+		}
+	}
+}
+
 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) {
@@ -428,6 +437,7 @@ static void glitch(const char *inPath, const char *outPath) {
 	scanlines();
 	reconData();
 	filterData();
+	if (options.invert) invert();
 	if (options.mirror) mirror();
 	free(lines);
 
@@ -476,7 +486,7 @@ int main(int argc, char *argv[]) {
 	char *output = NULL;
 
 	int opt;
-	while (0 < (opt = getopt(argc, argv, "a:cd:fmo:pr"))) {
+	while (0 < (opt = getopt(argc, argv, "a:cd:fimo:pr"))) {
 		switch (opt) {
 			break; case 'a':
 				options.applyFilter = parseFilters(options.applyFilters, optarg);
@@ -484,6 +494,7 @@ int main(int argc, char *argv[]) {
 			break; case 'd':
 				options.declareFilter = parseFilters(options.declareFilters, optarg);
 			break; case 'f': options.filt = true;
+			break; case 'i': options.invert = true;
 			break; case 'm': options.mirror = true;
 			break; case 'o': output = optarg;
 			break; case 'p': options.brokenPaeth = true;
rs Hjemli 2006-12-11Don't truncate valid cachefilesLars Hjemli 2006-12-11Move global variables + callback functions into shared.cLars Hjemli 2006-12-11Move functions for generic object output into ui-view.cLars Hjemli 2006-12-11Move log-functions into ui-log.cLars Hjemli 2006-12-11Move repo summary functions into ui-summary.cLars Hjemli 2006-12-11Move functions for repolist output into ui-repolist.cLars Hjemli 2006-12-11Move common output-functions into ui-shared.cLars Hjemli 2006-12-11Rename config.c to parsing.c + move cgit_parse_query from cgit.c to parsing.cLars Hjemli 2006-12-11Avoid infinite loops in caching layerLars Hjemli 2006-12-11Let 'make install' clear all cachefilesLars Hjemli 2006-12-11Fix cache algorithm loopholeLars Hjemli 2006-12-10Add version identifier in generated filesLars Hjemli 2006-12-10Add license file and copyright noticesLars Hjemli 2006-12-10Add caching infrastructureLars Hjemli