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:
parent
24fb139678
commit
f18c3cee6f
@ -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))
|
||||
{
|
||||
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]);
|
||||
}
|
||||
else
|
||||
{
|
||||
pix vpix = BLACK;
|
||||
return(vpix);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
x
Reference in New Issue
Block a user