Subject: | rotate new size calculation is incorrect, hides interpolation bug |
Date: | Mon, 4 Jul 2011 15:41:57 +1000 |
To: | bug-Imager [...] rt.cpan.org |
From: | tonyc [...] cpan.org |
Two bugs in i_rotate_exact_bg():
The code uses:
x1 = ceil(abs(src->xsize * rotate[0] + src->ysize * rotate[1]));
and similar code to calculate the new limits of the image, but abs()
takes and returns an integer, so the size can be up to one pixel too
small.
The interpolation done then doesn't correctly define the new color,
returning (255,33,33) or other non-max saturation reds. This is true
even with the intermediate image we produce, which the conversion to
paletted doesn't catch due to it's accuracy limits.
Replacing the abs() with fabs() fixes the first problem revealing the
second.