Skip to content

Fix the negative image only converting 1/3 of the image#8

Open
Absolute-Arthur wants to merge 2 commits intoabhijitnathwani:masterfrom
Absolute-Arthur:master
Open

Fix the negative image only converting 1/3 of the image#8
Absolute-Arthur wants to merge 2 commits intoabhijitnathwani:masterfrom
Absolute-Arthur:master

Conversation

@Absolute-Arthur
Copy link
Copy Markdown

This only modifies the negative_image.c

Currently, the width and height values are taken straight from the header, and used directly, assuming that 1 byte = 1 pixel. This results in corrupted image results, which, when viewed with a viewer handling this corruption, reveals that only 1/3 of the original image is treated and put in the result image.
The reason is that each pixel has 3 bytes, corresponding to the 3 colors of RGB.
Simply multiplying these values by 3 fixes this, allowing the memory allocations to ask for 3 times the size and treating the whole image.

@abhijitnathwani
Copy link
Copy Markdown
Owner

Hi @Absolute-Arthur
Thank you for the PR. Can you please share the image where you faced this issue ?
Thanks,
Abhijit

@Absolute-Arthur
Copy link
Copy Markdown
Author

It is really any BMP image I had, be it an image of a banana or an image of a landscape (converted using Paint).
Unfortunately Github does not support BMP attachements so I can't show you sorry.
I've also just realized that I did a small mistake in my fix, and multiplied the sizes by 9 instead of 3 (3*3=9), resulting in images being 3 times bigger and filled with nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants