|
From: Dima K. <gn...@di...> - 2023-06-12 02:40:58
|
Oh, and two more notes, where the old code had off-by-one errors
- There old code was set up to overlap each colorbox by extending the
bottom/right edge of each slice: GPMIN(xy_to,xy2+1)
But that logic applies to all the slices, even the last one. This
resulted in the last slice being one unit out-of-bounds
- The old code was computing the colors for each slice like this:
for (i = 0; i < steps; i++)
gray = i / (double)steps;
This is another off-by-one error. The colors in the colorbox spanned
[0,1-1/steps] instead of [0,1]. My patch fixes this one.
There's some funky logic in quanize_gray() that maybe is trying to
deal with this in the limited-max-colors case, but it's not commented,
and applies to only this case. Code:
qgray = floor(gray * sm_palette.use_maxcolors)
/ (sm_palette.use_maxcolors-1);
That should be made unnecessary
|