image: Improve resize quality at the edges.

get_pix() returns opaque black pixels for out-of-bounds coordinates, resulting
in spurious averages at the edges. The attached patch appears to fix the
problem, at least for the floating-point resizers.

From SF user R.L. Horn.
This commit is contained in:
Justin Maggard 2015-02-09 18:01:54 -08:00
parent 24fb139678
commit f18c3cee6f

View File

@ -210,15 +210,17 @@ image_free(image_s *pimage)
pix
get_pix(image_s *pimage, int32_t x, int32_t y)
{
if((x >= 0) && (y >= 0) && (x < pimage->width) && (y < pimage->height))
{
return(pimage->buf[(y * pimage->width) + x]);
}
else
{
pix vpix = BLACK;
return(vpix);
}
if (x < 0)
x = 0;
else if (x >= pimage->width)
x = pimage->width - 1;
if (y < 0)
y = 0;
else if (y >= pimage->height)
y = pimage->height - 1;
return(pimage->buf[(y * pimage->width) + x]);
}
void