sysprog21 / mado

A window system for resource-constrained devices
MIT License
39 stars 14 forks source link

Fix implementation of 8-bit pixmap transformation #12

Closed shengwen-tw closed 3 months ago

shengwen-tw commented 3 months ago

The function twin_pixmap_read_xform_8() applies a linear transformation to an 8-bit pixmap. Due to discretization considerations in computer graphics, the output is usually calculated using backward interpolation (i.e.,_pix_saucemix).

This commit identifies two potential bugs in the implementation. The first bug is that the coordinate calculation for pts[3] should be (sx + 1, sy + 1). The second bug is that _pix_saucemix() should take pts[3] instead of pts[4]. Using pts[4] not only violates the definition of twin_a8_t pts[4]; but also makes no sense since the four calls to _get_pix_8() are intended to obtain the top-left, top-right, bottom-left, and bottom-right pixels.

Additionally, this commit eliminates the only existing warnings in the project.

jserv commented 3 months ago

Thank @shengwen-tw for contributing!