sol-prog/cpp-bmp-images

Out of bounds error in set_pixel

ctralie opened this issue · 3 comments

Hello!
Thank you for this great example! It saved me a lot of time when I was trying to get a simple dependency-free image writer in a class on C++
My students and I did notice a little bug, though. It appears there is an out of bounds error on the line below in set_pixel if either x0 or y0 is exactly equal to the width or height, respectively

if (x0 > (uint32_t)bmp_info_header.width || y0 > (uint32_t)bmp_info_header.height) {

Otherwise, it seems to work quite well.

Also, I know this wasn't a super serious library and was mainly added for educational reasons, but I added some functionality here on drawing circles, lines, and characters:
https://github.com/Ursinus-CS174-F2020/Week14_BinarySearchTrees/blob/main/BMP.h
Best,
Chris Tralie

Hey @ctralie, perhaps you might want to submit your fix as a pull request? It would probably make it easier for the maintainer to incorporate.

Hello @ctralie, thanks for letting me know about the problem and for the solution. I'm glad my code was useful to you.