From ce216b1879e94dee92cef71b3309deee60b10cd5 Mon Sep 17 00:00:00 2001 From: Gentoo Date: Wed, 4 Mar 2026 22:52:18 -0500 Subject: [PATCH] he shoots and misses try again --- src/main.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/main.c b/src/main.c index 6f6f193..80e80ce 100644 --- a/src/main.c +++ b/src/main.c @@ -206,21 +206,33 @@ chromatic_circular_shift(unsigned int clr, int n) } unsigned int* -horizontal_flip(unsigned int* buf, int size, int w, int h) { - unsigned int* flip = malloc((w *h) * sizeof(unsigned int)); +horizontal_flip(unsigned int* buf, int size, int w, int h) +{ + unsigned int* flip = malloc((w * h) * sizeof(unsigned int)); + int idx = 0; + for (int i = 0; i < w; i++) + { + for (int k = h - 1; k >= 0; k--) + { + flip[idx] = buf[i * w + k]; + idx++; + } + } free(buf); return flip; - } unsigned int* -vertical_flip(unsigned int* buf, int size, int w, int h) { +vertical_flip(unsigned int* buf, int size, int w, int h) +{ unsigned int* flip = malloc((w * h) * sizeof(unsigned int)); int idx = 0; - for(int i = h - 1; i >= 0; i--) { - for(int k = 0; k < w; k++) { + for (int i = h - 1; i >= 0; i--) + { + for (int k = 0; k < w; k++) + { flip[idx] = buf[i * w + k]; idx++; } @@ -230,7 +242,6 @@ vertical_flip(unsigned int* buf, int size, int w, int h) { return flip; } - void print_bits_int(unsigned int n) { @@ -273,10 +284,10 @@ main() int max_val; unsigned int* buf = - ppm_encode("../test.ppm", &width, &height, &max_val, - magic_number); + ppm_encode("../test.ppm", &width, &height, &max_val, magic_number); // ppm_apply_brightness(buf, (width * height), .5); - buf = vertical_flip(buf, (width * height), width, height); + // buf = vertical_flip(buf, (width * height), width, height); + buf = horizontal_flip(buf, (width * height), width, height); ppm_decode(buf, (width * height), "../new.ppm", &width, &height); free(buf); return 0;