This fixes a bug with a screenshot stride mismatch I encountered when using:
- Sway with modification to allow RGB565 buffers, with: https://github.com/mstoeckl/sway/tree/extra-bit-depths
- Wayshot modified to take screenshots of RGB565 buffers, using the following branch: https://github.com/waycrate/wayshot/pull/32 . (
grim
does not work here, since a) it takes a screenshot of the complete output, not a region, and then edits it down b) Pixman cannot handle RGB565 buffers where stride % 4 = 2.)
To reproduce the issue/check that this MR corrects the behavior:
swaymsg output '*' render_bit_depth 5
wayshot -s "0 0 101 100" -f out.png
Documentation for glPixelStorei / GL_PACK_ALIGNMENT: https://docs.gl/es2/glPixelStorei