stb_image_write.h: Fix jpg flipping for non-multiple-of-8 sizes
Before adoption: this commit came in with the history the project adopted, so no landing records it.
JPG always encodes 8x8 pixel blocks. If the input image does not have a width or height that's a multiple of 8, the last column or row is just used multiple times for the remaining pixels of the block. The original code first calculated p (the index into the pixel data) with the "imaginary" row/colum (that might be up to 7 pixels too far into each direction) and then subtracted the necessary amount of bytes it if row >= height or col >= width. That was a bit cryptic (IMHO), and didn't get more readable/obvious when vertical flipping was added - which introduced a bug, by not taking stbi__flip_vertically_on_write into account when adjusting p for row >= height... The code should be more obvious (and less buggy) now. This fixes bug #592
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+8 added−6 removed
- other:+8 added−6 removed