From 0c727deb56e2a667f7738cd2e43e31fbcc46beac Mon Sep 17 00:00:00 2001 From: Arthur <61556875+Absolute-Arthur@users.noreply.github.com> Date: Thu, 14 Mar 2024 15:51:21 +0100 Subject: [PATCH 1/2] Triple width and height --- negative_image.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/negative_image.c b/negative_image.c index c64a06f..1fb0d9f 100644 --- a/negative_image.c +++ b/negative_image.c @@ -19,8 +19,8 @@ int main() // extract image height and width from imageHeader - int width = *(int*)&imageHeader[18]; - int height = *(int*)&imageHeader[22]; + int width = *(int*)&imageHeader[18] * 3; // each pixel has 3 bytes of data (red, green and blue) + int height = *(int*)&imageHeader[22] * 3; int bitDepth = *(int*)&imageHeader[28]; int imgDataSize = width * height; // calculate image size From d10dc24b45e34918661e8eba8df7348074387c47 Mon Sep 17 00:00:00 2001 From: Arthur <61556875+Absolute-Arthur@users.noreply.github.com> Date: Fri, 15 Mar 2024 14:59:39 +0100 Subject: [PATCH 2/2] Remove the *3 on the height --- negative_image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/negative_image.c b/negative_image.c index 1fb0d9f..edd0300 100644 --- a/negative_image.c +++ b/negative_image.c @@ -20,7 +20,7 @@ int main() // extract image height and width from imageHeader int width = *(int*)&imageHeader[18] * 3; // each pixel has 3 bytes of data (red, green and blue) - int height = *(int*)&imageHeader[22] * 3; + int height = *(int*)&imageHeader[22]; int bitDepth = *(int*)&imageHeader[28]; int imgDataSize = width * height; // calculate image size