Fix dithering and improve readability by WildRackoon · Pull Request #9338 · python-pillow/Pillow
Somes changes related to the dithering conversion code:
-
Fix RGB cache error values at the end of a row, not set to the right values (Blue values was used for R,G and B ?)
I believe this is a mistake, this affects only the last column of the image, so it is likely very minimal, but I still really would like a second opinion on that. -
Improved error diffusion readability, now the Floyd–Steinberg weights are readable through the code.
-
We should add more comments for posterity IMO, most of this dates back to the original PIL fork, the implementation is nicely optimized, but that makes the code slightly more confusing.
I mean look at this 😅:
| /* propagate errors (don't ask ;-) */ |
Future improvement includes adding more dithering kernels in the same optimized manner.
If anyone needs more details on those changes, I published a gist for that here: https://gist.github.com/WildRackoon/0030fc3d4db3f4af73e2cdac19bbdf6d