From f6b81413ab0a46a07bf2b049f2aacff46dd4106c Mon Sep 17 00:00:00 2001 From: ekanshgupta2046 Date: Tue, 21 Oct 2025 22:35:36 +0530 Subject: [PATCH] feat(image-filtering): add reflect function --- helpers.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/helpers.c b/helpers.c index 8275ef6..8cd928c 100644 --- a/helpers.c +++ b/helpers.c @@ -57,7 +57,18 @@ void sepia(int height, int width, RGBTRIPLE image[height][width]){ void reflect(int height, int width, RGBTRIPLE image[height][width]){ -// Reflect image horizontally + // Loop over each row + for (int i = 0; i < height; i++) + { + // Swap pixels horizontally (mirror) + for (int j = 0; j < width / 2; j++) + { + // Swap left pixel with right pixel + RGBTRIPLE temp = image[i][j]; + image[i][j] = image[i][width - 1 - j]; + image[i][width - 1 - j] = temp; + } + } }