Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Absolute-Arthur
Copy link

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
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
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