瀏覽代碼

* pixels.c: do not return a white pixel when calling getpixel() outside

the image boundaries; instead, return the closest pixel in the image.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2602 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
sam 16 年之前
父節點
當前提交
1871465283
共有 1 個文件被更改,包括 5 次插入5 次删除
  1. +5
    -5
      pipi/pixels.c

+ 5
- 5
pipi/pixels.c 查看文件

@@ -49,11 +49,11 @@ int pipi_getpixel(pipi_image_t const *img,
{
uint8_t *pixel;

if(x < 0 || y < 0 || x >= img->width || y >= img->height)
{
*r = *g = *b = 1.;
return -1;
}
if(x < 0) x = 0;
else if(x >= img->width) x = img->width - 1;
if(y < 0) y = 0;
else if(y >= img->height) y = img->height - 1;

pixel = img->pixels + y * img->pitch + x * img->channels;



Loading…
取消
儲存